msys2 / MSYS2-packages

Package scripts for MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
1.3k stars 490 forks source link

perl & git #4017

Open akshaal opened 1 year ago

akshaal commented 1 year ago

Description / Steps to reproduce the issue

Install perl, install git. Do

perl -e 'use Git;'

and observe:

Can't locate Git.pm in @INC (you may need to install the Git module) (@INC contains: /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 -e line 1.
BEGIN failed--compilation aborted at -e line 1.
ls /usr/share/perl5/

lists

FromCPAN/  Git/  core_perl/  site_perl/  vendor_perl/  Git.pm
export PERL5LIB=/usr/share/perl5

helps to workaround the problem.

Either git needs to install perl modules somewhere where perl5 can find it by default or perl5 needs to include /usr/share/perl5 in @INC by default.

Expected behavior

Git.pm should be included into perl5 @INC path by default.

Actual behavior

'git 'package installs Git.pm into a location where perl5 doesn't expect anything.

Verification

Windows Version

MINGW64_NT-10.0-22621 xxxxx 3.4.8.x86_64 2023-08-18 23:11 UTC x86_64 Msys

Are you willing to submit a PR?

No response

lazka commented 1 year ago

Thanks.

I can confirm that the issue also exists in Cygwin.

(I don't know anything about perl though and what the right thing to do would be)

rimrul commented 1 year ago

I've decided to look at how other packagers solve this problem. And for Msys2 there's two obvious candidates to compare to, because they bot use pacman. Git for Windows and Arch Linux.

Looking at how Git for Windows does this turned out to be unhelpful, because they mainly care about Gits perl scripts, that use use lib to find Git.pm. But looking towards Arch Linux seems promising.

They pass the perllibdir option with a value they get from perl to make when building Git.

https://gitlab.archlinux.org/archlinux/packaging/packages/git/-/blob/main/PKGBUILD?ref_type=heads#L47

perllibdir="$(/usr/bin/perl -MConfig -wle 'print $Config{installvendorlib}')"