Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ack-2.12 fails to run in Windows while ack-2.10 succeeds #425

Closed
passiontolearn opened this Issue · 10 comments

4 participants

@passiontolearn

Steps to reproduce:
1. Copy http://beyondgrep.com/ack-2.12-single-file to c:\Program Files\Ack\ack.pl
2. Add c:\Program Files\Ack\ to Windows PATH environment variable.
3. Run a search with ack.pl such as:
C:\ack.pl "hello"

Expected result:
Ack runs successfully like it did in version 2.10

Actual Result:
Can't use string ("C:\ProgramData\ackrc") as a HASH ref while "strict refs" in use at C:\Program Files\Ack\ack.pl line 4223.

Tested with: ActivePerl 5.16.3 Build 1603 (64-bit) on Windows 7 SP1 64 bit.

@petdance
Owner

Can you please verify for me that line 4223 of ack.pl is the my @lines = ... line in this block of code?

    foreach my $file ( @files) {
        my @lines = App::Ack::ConfigFinder::read_rcfile($file->{path});

        if(@lines) {
            push @arg_sources, {
                name     => $file->{path},
                contents => \@lines,
                project  => $file->{project},
            };
        }
    }
@petdance
Owner

And if that is indeed the case, please add this line before the foreach():

use Data::Dumper; print Dumper( \@files );

and then run it again and show us what it shows?

@passiontolearn

C:>ack.pl "hello"
$VAR1 = [
'C:\ProgramData\ackrc',
'C:\Users\MyUsername\AppData\Roaming\ackrc'
];
Can't use string ("C:\ProgramData\ackrc") as a HASH ref while "strict refs" in use at C:\Program Files\Ack\ack.pl line 4224.

C:>

@petdance
Owner

Thanks. That gives us to go off of, I think. @files should contain hashrefs, but it doesn't.

@passiontolearn

Ok I did some very basic testing and the following seems to fix it, change line 4223 from:
my @lines = App::Ack::ConfigFinder::read_rcfile($file->{path});
to:
my @lines = App::Ack::ConfigFinder::read_rcfile($file);

Looks like the bug was the dereference $file->{path}

@petdance
Owner

That'll fix it in your specific case, but the real question is why does @lines contain filenames instead of hashrefs.

@passiontolearn

I don't think it's supposed to contain hashrefs but I didn't write the code :)

Just do a diff with ack-2.10 : http://beyondgrep.com/ack-2.10-single-file

The signature of the read_rcfile sub has remained the same too (as has it's implementation) so looks like the dereference "->{path}" snuck in there somehow... (bug)

@pdl

Looks like it's related to #419 / #417

@maxlybbert

I ran into this bug today, and planned to report it. If this is still not fixed, the bug comes from the Windows-only path of _remove_redundancies. Namely, the loop that starts on line 3410 should be:

    foreach my $path (@configs) {
        push @uniq, $path unless $seen{$path->{path}};
        $seen{$path} = 1;
    }

Or:

    foreach my $path (map { $_->{path} } @configs) {
        push @uniq, { path => $path } unless $seen{$path};
        $seen{$path} = 1;
    }
@petdance
Owner

This method has been refactored in the last version 2.13_04, or at least it's on the current dev.

@petdance petdance closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.