14

I am trying to use use cpan on my windows install version of Git Bash git version 2.18.0.windows.1. I installed an Active Perl version version 24, subversion 3 (v5.24.3) built for MSWin32-x64-multi-thread and it is located in C:\Perl64\bin\perl.exe. I can run cpan in the cmd under windows just fine but I cannot seem to get it to run in git bash because of the perl5 that comes with it. I either get this error:

Can't locate CPAN/Author.pm in @INC (you may need to install the CPAN::Author module) (@INC contains: /c/Perl64/site/bin /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at /usr/share/perl5/core_perl/CPAN.pm line 19. BEGIN failed--compilation aborted at /usr/share/perl5/core_perl/CPAN.pm line 19. Compilation failed in require at /c/Octave/Octave-4.4.1/bin/cpan line 119. BEGIN failed--compilation aborted at /c/Octave/Octave-4.4.1/bin/cpan line 119.

Or when I add the folder than holds the CPAN folder and consequently Perl folder to the @INC path with export PERL5LIB=/c/Perl64/lib I get this error:

Cwd.c: loadable library and perl binaries are mismatched (got handshake key 0000000600000570, needed 0000000000000000)

Here is print out of @INC path after addition:

~$ perl -e "print qq(@INC)" /c/Perl64/lib /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl~$

How can I make sure git bash runs cpan like it does in windows?

The full paths that were added when I installed ActivePerl are C:\Perl64\bin which holds the lib folder which holds the CPAN folder (and in it the Author.pm file) and C:\Perl64\site\bin and cpan runs fine in windows cmd.

I am ultimately trying to configure and install packages all my self learning for git bash and got to these problems because when I try to configure I get this issue. Been at it for 16 of last 24 hours:

intltool-0.51.0$ ./configure --prefix=/mingw

checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... no checking whether make supports nested variables... yes checking for perl... /usr/bin/perl checking for perl >= 5.8.1... 5.26.2 checking for XML::Parser... configure: error: XML::Parser perl module is required for intltool

Brian Wiley
  • 485
  • 2
  • 11
  • 21
  • You will need to set up `$PATH` under bash so that `/cygdrive/C/Perl64/bin` comes before `/bin/` (or wherever the Git `perl` lives). This might screw up `git` or other of its tools for you, so proceed with caution. – Corion Dec 15 '18 at 08:34
  • so I added it first and `which perl` points to that one now but when i enter `cpan` i still get the first error `Can't locate CPAN/Author.pm in @INC (you may need to install the CPAN::Author module)` it keeps trying to run `/usr/share/perl5/core_perl/CPAN.pm line 19` from the git perl – Brian Wiley Dec 15 '18 at 09:18
  • 1
    You will also need to add the directory where the correct `cpan.bat` sits to the front of `$PATH`. Maybe that's `/cygdrive/C/Perl64/perl/bin` or something. This is mostly a shell question and not a Perl question. – Corion Dec 15 '18 at 10:04
  • thanks, i will try that, i was able to run the configure file without it however now when running `make` i get this error `make: /bin/sh: Command not found make: *** [Makefile:460: all-recursive] Error 127`. i should probably create a new question cause i cannot find answer – Brian Wiley Dec 15 '18 at 10:06
  • You still got programs from the `perl` distributed with `git` in your path before the programs from the `perl` you want to use. You will really need to clean up your $PATH variable, or maybe settle on not using Cygwin. – Corion Dec 15 '18 at 10:11
  • yes thanks, it seems that you will always run into issues if you use cygwin and git, lot of resources say you cannot do it, i just updated my git for the new packages, thanks! – Brian Wiley Dec 15 '18 at 20:02
  • @BrianWiley, so the solution for this was...? I tried to put `/usr/bin/vendor_perl` and `/usr/bin/core_perl` at the beginning of the path and its not working. – Adrian Jun 28 '19 at 16:20

1 Answers1

0

You can install perl natively on windows, then alias your gitbash to that perl. In my case, I've install perl to C:\Perl64, then I add to my ~/.bashrc

alias perl=/c/Perl64/bin/perl.exe

GitBash will then use the perl you've installed instead of the perl delivered with git.

ctNGUYEN
  • 241
  • 2
  • 6
  • 3
    I tried that, but it did not work. Its still using the perl from /usr/bin. I have the original perl also in PATH, and 'where perl' showes me both locations. I renamed the git-bash-perl then git-bash decided to use the other perl. – Philipp Michalski Jul 20 '20 at 08:14