beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 140 forks source link

Cygwin + Strawberry Perl + Ack 2.04 Troubles #267

Closed diego898 closed 11 years ago

diego898 commented 11 years ago

Hello,

I've managed to successfully install ack using cpan App::Ack from a windows command prompt. It installed correctly. I can run it just fine from the windows command prompt. However, when I try to run it form cygwin bash, I get the following:

$ack
Can't open perl script /c/strawberry/perl/site/bin/ack": No such file or directory. 

However, it does exist there:

$pwd
/c/strawberry/perl/site/bin
$ls
ack   ack.bat
$which ack
/c/strawberry/perl/site/bin/ack
$which perl
/c/strawberry/perl/bin/perl
mmcclimon commented 11 years ago

Ok, it looks like (at least on my machine), the executable is installed in /c/strawberry/perl/site/bin/ack, but the library files are in /c/strawberry/perl/site/lib. If I add the line use lib '../lib'; to the top of ack in the bin directory it seems to work for me. Could you see if that works? Then maybe we can get something so it would install correctly without modification.

diego898 commented 11 years ago

Thanks for the suggestion @mmcclimon but so far I've added the line to the following file: C:\strawberry\perl\site\bin\ack so that the first 6 lines read like:

#!/usr/bin/perl
use lib '../lib';
use strict;
use warnings;

use 5.008008;

However, I still get the same message:

$ack
Can't open perl script /c/strawberry/perl/site/bin/ack": No such file or directory. 

When I navigate to the /c/strawberry/perl/site/lib folder and do ls I get the following:

myname@host: /c/strawberry/perl/site/lib
$ ls -al
total 0
drwx------+ 1 SYSTEM SYSTEM 0 Apr 29 10:35 .
drwx------+ 1 SYSTEM SYSTEM 0 Apr  9 15:11 ..
d---------+ 1 myname None   0 Apr 29 10:35 App
d---------+ 1 myname  None   0 Apr 23 16:12 File
d---------+ 1 myname  None   0 Apr 29 10:35 auto
mmcclimon commented 11 years ago

Ok, I think I see the problem now. Strawberry Perl is built for MSWin32, but Cygwin uses a different Perl (/usr/bin/perl on my system). These two things aren't compatible with one another. I think (but am not sure...I'm not really a Windows user) you have to also install App::Ack from the Cygwin CPAN for it to work there. See this question on StackOverflow has slightly more explanation.

diego898 commented 11 years ago

I came across this article and added a symlink to make strawberry perl serve as cygwin's perl

myname@host /usr/bin
$ ls -al perl*
lrwxrwxrwx 1 myname None 31 Apr 29 11:15 perl -> /c/strawberry/perl/bin/perl.exe

For completeness, perl does indeed report MSWin32 as its os:

myname@host ~
$ perl -V:osname
osname='MSWin32';

Update: I've come across this article, and the issue does indeed seem to be a cygwin/windows path specifying one. When I type out the full path it does work:

myname@host ~
$ c:/strawberry/perl/site/bin/ack
...
This is version 2.04 of ack.
petdance commented 11 years ago

It sounds like there's good progress here. We definitely do not want to be going down the road of modifying ack to do use lib monkeying.

diego898 commented 11 years ago

For others that may have this issue in the future, what finally worked for me was following the advice mentioned in this article, and changing the path to be my strawberry perl. My final script can be found here. In other words, inside of the C:\cygwin\bin directory, create a new file called perl and make its contents those listed in the gist linked above (changing the cygwin and strawberry perl directories if necessary).

mmcclimon commented 11 years ago

In that case, I'm marking this as closed, since the problem doesn't appear to be with ack. Glad you got it working!