miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
750 stars 213 forks source link

cpanm fails to install XML::LibXSLT and later reports the module as installed on macOS 11.2.3 #628

Closed hakonhagland closed 3 years ago

hakonhagland commented 3 years ago

I am using the system perl version 5.28.2 on macOS 11.2.3 :

$ sudo cpan App::cpanminus
$ sudo cpanm -v XML::LibXSLT
cpanm (App::cpanminus) 1.7044 on perl 5.028002 built for darwin-thread-multi-2level
Work directory is /Users/hakonhaegland/.cpanm/work/1623300613.61292
You have make /usr/bin/make
You have LWP 6.44
You have /usr/bin/tar: bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6
You have /usr/bin/unzip
--> Working on .
Entering /Users/hakonhaegland/perl/install-cpan-modules/XML-LibXSLT-1.99
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.34)
Configuring XML-LibXSLT-1.99
Running Makefile.PL
running pkg-config libxslt... ok
looking for -lxslt... libxslt not found
Try setting LIBS and INC values on the command line
Or get libxslt and libxml2 from
  http://www.libxml.org/
If you install via RPMs, make sure you also install the -devel
RPMs, as this is where the headers (.h files) are.
no
-> N/A
! Configuring XML-LibXSLT-1.99 failed. See /Users/hakonhaegland/.cpanm/work/1623300613.61292/build.log for details.

$ sudo cpanm XML::LibXSLT
XML::LibXSLT is up to date. (1.99)

$ sudo cpanm -U  XML::LibXSLT
! XML::LibXSLT is not found in the following directories and can't be uninstalled.

  /Library/Perl/5.28/darwin-thread-multi-2level
  /Library/Perl/5.28

$ perl -MXML::LibXSLT -E 'say $INC{"XML/LibXSLT.pm"}'
/System/Library/Perl/Extras/5.28/darwin-thread-multi-2level/XML/LibXSLT.pm

Observe that cpanm -U looks in /Library/Perl/5.28 whereas cpanm apparently installed it in /System/Library/Perl/Extras/5.28

hakonhagland commented 3 years ago

See also this on stackoverflow.com.

miyagawa commented 3 years ago

I suppose there's something weird going on with MacOS perl. You can run cpanm -V to show the install paths cpanm would try to install and look for with your current environment.

hakonhagland commented 3 years ago

Yes, this looks strange... Here is the output:

$ cpanm -V
cpanm (App::cpanminus) version 1.7044 (/usr/local/bin/cpanm)
perl version 5.028002 (/usr/bin/perl)

  %Config:
    archname=darwin-thread-multi-2level
    installsitelib=/Library/Perl/5.28
    installsitebin=/usr/local/bin
    installman1dir=/usr/share/man/man1
    installman3dir=/usr/share/man/man3
    sitearchexp=/Library/Perl/5.28/darwin-thread-multi-2level
    sitelibexp=/Library/Perl/5.28
    vendorarch=/Network/Library/Perl/5.28/darwin-thread-multi-2level
    vendorlibexp=/Network/Library/Perl/5.28
    archlibexp=/System/Library/Perl/5.28/darwin-thread-multi-2level
    privlibexp=/System/Library/Perl/5.28
  %ENV:
    PERLBREW_HOME=/Users/hakonhaegland/.perlbrew
    PERLBREW_PATH=/Users/hakonhaegland/perl5/perlbrew/bin
    PERLBREW_ROOT=/Users/hakonhaegland/perl5/perlbrew
    PERLBREW_SHELLRC_VERSION=0.88
    PERLBREW_VERSION=0.88
  @INC:
    FatPacked::140633520029008=HASH(0x7fe7cb013d50)
    /Library/Perl/5.28/darwin-thread-multi-2level
    /Library/Perl/5.28
    /Network/Library/Perl/5.28/darwin-thread-multi-2level
    /Network/Library/Perl/5.28
    /Library/Perl/Updates/5.28.2/darwin-thread-multi-2level
    /Library/Perl/Updates/5.28.2
    /System/Library/Perl/5.28/darwin-thread-multi-2level
    /System/Library/Perl/5.28
    /System/Library/Perl/Extras/5.28/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.28
miyagawa commented 3 years ago

I'd suspect it might be that you have perlbrew environment mixed up with the system perl, and cpanm is in /usr/local/bin. Things could go wrong with this type of environment. At least I suggest you to unset these env vars to get perlbrew out of the way.

It looks to me XML::LibXSLT comes pre installed with macOS Big Sur (confirmed locally on my Mac) so the only thing that would be weird is that the first run of your cpanm XML::LibXSLT was trying to install it, when it doesn't need to.

Is it possible that the cpanm command was running from a different perl (i.e. /usr/local/bin/perl, or some other perl via perlbrew)?

hakonhagland commented 3 years ago

Is it possible that the cpanm command was running from a different perl

It is very possible, but if I type

$ which cpanm
/usr/local/bin/cpanm
$ which perl
/usr/bin/perl

I can also see that cpanm is using /usr/bin/perl by typing

$ head -1 /usr/local/bin/cpanm
#!/usr/bin/perl

So it seems it is using the correct perl..

miyagawa commented 3 years ago

yeah but that's after the fact, and not sure which perl cpanm was using in your first run. If you have a cpanm log file for that run in ~/.cpanm/work it might show which perl it was using in the log.

miyagawa commented 3 years ago

Actually, nevermind, you ran it with -v and the output is already there. It doesn't exactly say which perl it was using but at least the version number looks the same.

miyagawa commented 3 years ago

You know, what's weird is this line:

$ sudo cpanm -v XML::LibXSLT
cpanm (App::cpanminus) 1.7044 on perl 5.028002 built for darwin-thread-multi-2level
Work directory is /Users/hakonhaegland/.cpanm/work/1623300613.61292
You have make /usr/bin/make
You have LWP 6.44
You have /usr/bin/tar: bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6
You have /usr/bin/unzip
--> Working on .
Entering /Users/hakonhaegland/perl/install-cpan-modules/XML-LibXSLT-1.99

Working on . suggests that you ran it in a way with cpanm --installdeps . with XML::LibXSLT in cpanfile, or something along these lines. If you actually ran cpanm -v XML::LibXSLT, it should say Working on XML::LibXSLT.

Did you properly paste the output as-is, or did you modify the output?

hakonhagland commented 3 years ago

Did you properly paste the output as-is, or did you modify the output?

Yes good observation. I did paste the output from log file. I remember I first ran cpanm --installdeps . from the XML::LibXSLT source directory. I also thought that --installdeps would only install the dependencies not the module itself.. Then I think I saw that it actually installed the module. Probably something happened at this point that messed things up?

miyagawa commented 3 years ago

OK, that explains.

cpanm --installdeps . in XML::LibXSLT source directory would install the dependencies of the module, but not XML::LibXSLT itself. But, to get the list of dependencies, cpanm has to run perl Makefile.PL, aka configuring the module. Because XML::LibXSLT is an XS module which needs C libraries, the configuration failed.

That's what happened. Now, because XML::LibXSLT comes installed with macOS, an actual run of cpanm XML::LibXSLT doesn't install anything, saying it's already installed.

I'm closing this issue since I don't see a problem with how cpanm behaves here.