Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#43741 closed defect (worksforme)

cpan fails to install any module

Reported by: Polyergic (Shad Sterling) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mojca (Mojca Miklavec), dbevans (David B. Evans)
Port: perl5 perl5.16

Description

Any attempt to install a module with cpan fails with the following error:

Can't locate object method "requirements_for_module" via package "CPAN::Meta::Requirements" at /opt/local/lib/perl5/5.16.3/CPAN/Distribution.pm line 2802.

perl5.16 @5.16.3_0+universal and p5.16-cpan-meta-requirements @2.125.0_0 are installed and active.

Change History (13)

comment:1 Changed 11 years ago by mf2k (Frank Schima)

Have you seen this wiki page?

comment:2 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Does this problem occur when you install p5.16-* ports, or only when you try to install modules outside of MacPorts using the cpan command? If only the latter, then we recommend installing p5.16 ports instead. If a port for the module you want is missing, you can create and hopefully submit one as mf2k said above.

comment:3 Changed 11 years ago by Polyergic (Shad Sterling)

It occurs only when I try to install modules using the cpan command, which I've only done for modules that are not available as ports (specifically, IO::Socket::INET6). If I can get cpan to work I would prefer the one-command install to the lengthy process on the wiki page.

Judging by the responses on perl bug #121901, the problem is that the macports package perl5 @5.12.4_0+perl5_16 includes a version of /opt/local/bin/cpan that is incompatible with perl 5.16.3. (My perl5.16 was installed as a dependency of perl5.)

I have cpan version 2.05, but for perl 5.16.3 it should be cpan version 1.98.

comment:4 Changed 11 years ago by Polyergic (Shad Sterling)

By uninstalling and reinstalling perl5 and perl5.16, cpan was reverted to the matching version 1.98. Now it looks like telling cpan to update itself will update cpan to an incompatible version.

comment:5 Changed 9 years ago by mojca (Mojca Miklavec)

Cc: mojca@… devans@… added
Port: perl5 added
Version: 2.2.1

See also #50000.

comment:6 Changed 9 years ago by mojca (Mojca Miklavec)

Just curious: what happens if you delete (backup) your current .cpan directory (and possibly also $HOME/perl5)?

The cpan command works for me, but it installs files to $HOME/perl5 which is something that I don't particularly like. And there is no versioning involved anywhere, so I assume that I would end up with broken binary modules after perl upgrades.

comment:7 Changed 9 years ago by Polyergic (Shad Sterling)

I gave up on using cpan from macports, found another way to do whatever I needed when I filed this, and put a script named cpan in my path that tells me to either find the port or follow the instructions at https://trac.macports.org/wiki/howto/cpan2port

comment:8 in reply to:  6 Changed 9 years ago by dbevans (David B. Evans)

Replying to mojca@…:

Just curious: what happens if you delete (backup) your current .cpan directory (and possibly also $HOME/perl5)?

The cpan command works for me, but it installs files to $HOME/perl5 which is something that I don't particularly like. And there is no versioning involved anywhere, so I assume that I would end up with broken binary modules after perl upgrades.

Maybe you're using the system cpan in /usr/bin ?

comment:9 Changed 9 years ago by mojca (Mojca Miklavec)

No, I was also testing with cpan-5.22, leading to the same effect. It asked for location of course the first time I tried, but that was the default (lacking permissions to put modules somewhere deep under ${prefix}).

comment:10 Changed 9 years ago by dbevans (David B. Evans)

Then you probably need to run cpan with sudo. The following works for me.

sudo port install perl5

which gives

$ which perl cpan
/opt/local/bin/perl
/opt/local/bin/cpan
$ perl -v
This is perl 5, version 22, subversion 1 (v5.22.1) built for darwin-thread-multi-2level
...
$ cpan -v
/opt/local/bin/cpan script version 1.63, CPAN.pm version 2.11

so I won't bother with the 5.22 suffix stuff.

If I then run

sudo cpan

I can install whatever I like and it gets installed into the perl5.22 site path

/opt/local/lib/perl5/site_perl/5.22

MacPorts modules install into the vendor path

/opt/local/lib/perl5/vendor_perl/5.22

and core modules are in the main path

/opt/local/lib/perl5/5.22

So CPAN, MacPorts and CPAN can all have the same module installed without conflict

Looking at @INC

perl -e "print join(\"\n\", @INC), \"\n\""
/opt/local/lib/perl5/site_perl/5.22/darwin-thread-multi-2level
/opt/local/lib/perl5/site_perl/5.22
/opt/local/lib/perl5/vendor_perl/5.22/darwin-thread-multi-2level
/opt/local/lib/perl5/vendor_perl/5.22
/opt/local/lib/perl5/5.22/darwin-thread-multi-2level
/opt/local/lib/perl5/5.22
.

you can see, from the search order, that MacPort's vendor installed modules will override core, but CPAN's site installed modules will override MacPort's.

So if you have all three installed CPAN wins.

Using the very useful whichpm script, if I install Net::FTP, which is a core module, using both MacPorts and CPAN I see

$ whichpm Net::FTP
whichpm: WARNING: DUPLICATE module files found for 'Net::FTP':
  /opt/local/lib/perl5/vendor_perl/5.22/Net/FTP.pm (from p5-net)
  /opt/local/lib/perl5/5.22/Net/FTP.pm (from core)
/opt/local/lib/perl5/site_perl/5.22/Net/FTP.pm (from cpan)

the last one is the version that perl will load due to the @INC search order.

comment:11 Changed 9 years ago by dbevans (David B. Evans)

Resolution: worksforme
Status: newclosed

comment:12 Changed 9 years ago by mojca (Mojca Miklavec)

I was avoiding sudo on purpose. It's probably a different question anyway, but is there a way to make user-installed modules visible to that user only? Should the @INC also contain $HOME/.cpan/whatever/comes/next? Or is that a security risk in a way / or something that's not really acceptable?

comment:13 Changed 9 years ago by dbevans (David B. Evans)

This comes under the heading of finding modules in non-standard locations. There's a couple of ways to do this. See the discussion here.

Note: See TracTickets for help on using tickets.