How can I modify my cygwin environment to use Stra

2019-02-06 08:35发布

I currently use Strawberry Perl as my primary Perl distribution. However, I have some applications that make Perl calls through cygwin. These generally fail because they are calling the version of Perl that was packaged with cygwin, and only looking in cygwin's lib folders. How can I modify my cygwin environment to call Strawberry Perl (and use the C:/strawberry/perl/lib dirs) instead?

8条回答
Rolldiameter
2楼-- · 2019-02-06 08:53

I don't have my cygwin machine nearby so I can't test this, but perhaps you can front-end the perl command with a script: go to /bin under cygwin and move the perl.exe there to something else like perl-org.exe, then set up a shell script that execs your other perl with the same arguments.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-02-06 09:02

You can change your PATH to put the Strawberry directories first. Strawberry tries to be nice by putting its directories at the end of the PATH. If you installed from the .zip file, however, it didn't change the PATH at all.

You could move /usr/bin/perl, but that's a bad idea since it breaks when cygwin tries to update what it thinks is its perl. I just had that happen to me this week and used to happen to me on my Mac until I stopped playing with the system setup and installed my own stuff completely separate.

查看更多
干净又极端
4楼-- · 2019-02-06 09:04

If you remove Perl from cygwin using the setup program it will use Strawberry Perl by default.

If you are unable to remove Perl from cygwin, you can create a symbolic link to the Perl executable from Strawberry.

From a cygwin shell, use the following set of commands:

$ mv /usr/bin/perl /usr/bin/perl-cygwin
$ ln -s /cygdrive/c/strawberry/perl/bin/perl.exe /usr/bin/perl

This is assuming you used the default Strawberry Perl installer. Update your perl.exe location accordingly if you have it installed somewhere else.

Check to make sure the link is working properly by checking the Perl version:

$ perl -v

It should say This is perl, (version) built for MSWin32-x86-multi-thread (or similar) and not built for cygwin-thread-multi-64int.

查看更多
Anthone
5楼-- · 2019-02-06 09:04

Many of these are good solutions, but I rather take an easy one that I don't have to modify more than once.

All you need to do is add/modify a line in your .bashrc file.

# Prepend strawberry perl to cygwin's path
export PATH=/cygdrive/C/Tools/Perl/perl/bin:$PATH

source .bashrc file from your shell, (or start a new shell) and run your program.

source ~/.bashrc
perl script.pl 
查看更多
我想做一个坏孩纸
6楼-- · 2019-02-06 09:06

I have two scripts that I use to modify the first line of Perl scripts to whichever Perl is first in my path: rightperl hardcodes to the Perl that is first in my $PATH now, envperl will change the line to #!/usr/bin/env perl so the Perl to use is only picked at the time the script is invoked. Works really well under Cygwin (and from a Unix shell in general).

查看更多
The star\"
7楼-- · 2019-02-06 09:08

This is probably not a preferred solution, but you should be able to modify the #! line:

#!/cygdrive/c/strawberry/perl/bin/perl5.10.0

I always refer to an explicit location and installation of perl, rather than relying on what is in /usr/bin.

查看更多
登录 后发表回答