3

I am wondering why I get "Installing the dependencies failed: Module 'Module::Name' is not installed" even when dependency is has been installed. I am using perlbrew and cpanm. Here is an example of what happens with many modules that I try to install:

  1. I try to install for example URI::ws as follow
hamid@caspian:~$ /home/hamid/perl5/perlbrew/bin/cpanm --installdeps URI::ws
--> Working on URI::ws
Fetching http://www.cpan.org/authors/id/P/PL/PLICEASE/URI-ws-0.03.tar.gz ... OK
Configuring URI-ws-0.03 ... OK
==> Found dependencies: URI
--> Working on URI
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/URI-1.67.tar.gz ... OK
Configuring URI-1.67 ... OK
Building and testing URI-1.67 ... OK
Successfully installed URI-1.67
! Installing the dependencies failed: Module 'URI' is not installed
! Bailing out the installation for URI-ws-0.03.
1 distribution installed
  1. it tells me URI is not installed. So I install URI as follow:
hamid@caspian:~$ /home/hamid/perl5/perlbrew/bin/cpanm URI
--> Working on URI
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/URI-1.67.tar.gz ... OK
Configuring URI-1.67 ... OK
Building and testing URI-1.67 ... OK
Successfully installed URI-1.67
1 distribution installed
  1. I go back to what I originally wanted which was URI::ws and here is what I get:
hamid@caspian:~$ /home/hamid/perl5/perlbrew/bin/cpanm URI::ws
--> Working on URI::ws
Fetching http://www.cpan.org/authors/id/P/PL/PLICEASE/URI-ws-0.03.tar.gz ... OK
Configuring URI-ws-0.03 ... OK
==> Found dependencies: URI
--> Working on URI
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/URI-1.67.tar.gz ... OK
Configuring URI-1.67 ... OK
Building and testing URI-1.67 ... OK
Successfully installed URI-1.67
! Installing the dependencies failed: Module 'URI' is not installed
! Bailing out the installation for URI-ws-0.03.
1 distribution installed

Can anyone tell me why this is happening and what I can do to stop it? If there is any more information that you need which I have missed please let me know.

Thank you

G. Cito
  • 6,210
  • 3
  • 29
  • 42
Hamster
  • 680
  • 7
  • 23
  • 1
    Where was URI installed? From where did `cpanm` try to read it? – choroba Mar 10 '15 at 12:46
  • @choroba : hamid@caspian:~$ perl -MURI -e 'print $INC{"Time/HiRes.pm"}' Can't locate URI.pm in @ INC – Hamster Mar 10 '15 at 13:01
  • Your `cpanm` is installed at an odd location; is it running via the correct `perl`? – friedo Mar 10 '15 at 13:10
  • 4
    @friedo to make things work a bit more smoothly [perlbrew](http://www.perlbrew.pl) can [install its own `cpanm`](http://www.perlbrew.pl/Perlbrew-and-Friends.html) - so that is probably OK. What can interfere with things is if you mix your own [`local::lib`](https://metacpan.org/pod/local::lib) and env vars like `$PERL5LIB` with perlbrew's environment (it is of course possible to use `local::lib` environments "inside" perlbrew with the `lib` command). @Hamster is URI installed for the version of perl your perlbrew is using? (*i.e.* are the files present in the perlbrew directory hierarchy). – G. Cito Mar 10 '15 at 13:52
  • @G.Cito I am using the latest version of Perl (5.20.2) and no, `find ~/perl5/perlbrew/ -name "*URI*"` gives me nothing – Hamster Mar 10 '15 at 13:59
  • 2
    It looks like it is getting installed somewhere :-) Are all the right `PERLBREW_` env vars set? Anything like `PERL_CPANM_OPT` ,`PERL_LOCAL_LIB_ROOT` or `PERL5LIB` present in your environment that might be mucking things up? – G. Cito Mar 10 '15 at 14:20

2 Answers2

5

Thanks to https://stackoverflow.com/users/2019415/g-cito

hamid@caspian:~$ PERL_MM_OPT=""; PERL_MB_OPT="";

has done the job :)

local::lib was messing stuff up. URI.pm was installed but not under the perlbrew directory.

Community
  • 1
  • 1
Hamster
  • 680
  • 7
  • 23
  • 2
    If you have `local::lib` configured, you should check your `.bashrc` (or equivalent for your shell); `PERL_MM_OPT` and `PERL_MB_OPT` are probably set there. – ThisSuitIsBlackNot Mar 10 '15 at 16:57
  • Added comments as an answer if you want to accept it :-) Be sure to heed @ThisSuitIsBlackNot's advice ++ – G. Cito Mar 10 '15 at 17:19
  • This solution worked for me. Edit /root/.bashrc , set the variables to PERL_MM_OPT=""; PERL_MB_OPT=""; then reload bash with: source /root/.bashrc then reinstall modules – Y.K. Jul 02 '23 at 11:53
2

With perlbrew you can install a perlbrew specific cpanm which facilitates installing to the various perls/ that are installed/managed using the perlbrew tool. I have found that this works very well.

However perlbrew can become confused if you mix in your own local::lib and set related environment variables like PERL5LIB, PERL_MM_OPT, PERL_MB_OPT etc. (see for example the post by @cjm in perlbrew and local::lib at the same time?). Some of these environment vars can interact and interfere with perlbrew's own environment so it's generally best to avoid mixing them or simply to let perlbrew manage the environment using its own versions of those variables.

It is of course possible to use local::lib environments "inside" perlbrew with the lib command) and to do very complicated things for testing with different perl versions, shipping an application with requirements (c.f. Carton). In my own environment I was able to manage system perl; a user installed local::lib that used the system perl; and a huge set of perlbrew perls all with judicious use of environment variables (thankfully a temporary set up while migrating between versions).

That sort of set up can get complicated very quickly, and is difficult to replicate. One of the greatest advantages of perlbrew is you can easily setup matching perl environments on multiple machines; or different perl environments on the same machine.

Community
  • 1
  • 1
G. Cito
  • 6,210
  • 3
  • 29
  • 42