petdance/ack2 — Issue #7: App::Ack::Resource::Basic attempts to open directories for reading with open()
Author: packy
Created: 2011-11-29 00:08:29+00:00
State: open

When I try to search my source tree, I get the following error:

$ ack2 -l FOO
ack: .git: Permission denied
Can't call method "name" on an undefined value at d:/git/ack2/ack line 1247.

I was able to trace this back to App::Ack::Resource::Basic line 37, which attempts to open the file it's been passed for reading. If this file is a directory, then this attempt fails (yielding the "Permission denied" error) and the method returns no object (which explains the "Can't call method on undefined value" error immediately afterward). If I make a local modification to the module so line 37 reads

if ((! -d $self->{filename}) && !open( $self->{fh}, '<', $self->{filename} ) ) {

then I get the following output:

$ ack2 -l FOO
Doxyfile
lib/GA/MiddleTier/Ops/Sync/WizardData/Mssql.pm