Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

cpan client- install_base value not used to install Text::Table

by Anonymous Monk
on Sep 12, 2019 at 15:43 UTC ( [id://11106074]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I was trying to install a module in my own directory via cpan (tried with perl 5.16.3 on CentOS 7; perl 5.30.0 on FreeBSD 12) but failed because install process tried to install Text::Table and Text::Aligner dependencies in a system wide directory (/usr/local) not writable by me as a lowly non-root user.

I had checked that the right directory had been specified for both Build.PL & Makefile.PL. What am I missing in the CPAN configuration file?

cpan[2]> o conf /make|build|install/ $CPAN::Config options from /home/parv/.cpan/CPAN/MyConfig.pm: build_cache [100] build_dir [/home/parv/.cpan/build] build_dir_reuse [0] build_requires_install_policy [yes] cleanup_after_install undef make [/usr/bin/make] make_arg [] make_install_arg [PREFIX=/home/parv/test-perl5] make_install_make_command [/usr/bin/make] makepl_arg [PREFIX=/home/parv/test-perl5] mbuild_arg [--install_base /home/parv/test-perl5] mbuild_install_arg [] mbuild_install_build_command [./Build] mbuildpl_arg [] prefer_installer [MB]
# cpan client - FAILED on CentOS & FreeBSD. . . .---- JETTERO/Term-ANSIColorx-ColorNicknames-2.7191.tar.gz ---- Text::Table [requires] Running install for module 'Text::Table' . . . Building Text-Table SHLOMIF/Text-Table-1.133.tar.gz ./Build --install_base /home/parv/test-perl5 --prefix /home/parv/tes +t-perl5 --install_base /home/parv/test-perl5 --prefix /home/parv/test +-perl5 -- OK Running Build test for SHLOMIF/Text-Table-1.133.tar.gz . . . Result: PASS SHLOMIF/Text-Table-1.133.tar.gz ./Build test -- OK Running Build install for SHLOMIF/Text-Table-1.133.tar.gz Building Text-Table !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! ERROR: Can't create '/usr/local/lib/perl5/site_perl/Text' mkdir /usr/local/lib/perl5/site_perl/Text: Permission denied at /usr/l +ocal/lib/perl5/5.30/ExtUtils/Install.pm line 489.
# Manually issued command - SUCCEEDED on FreeBSD (hadn't tried on Cent +OS yet). perl Build.PL --install_base /home/parv/test-perl5/ && ./Build && ./Bu +ild test && ./Build install Created MYMETA.yml and MYMETA.json Creating new 'Build' script for 'Text-Table' version '1.133' Building Text-Table . . . Result: PASS Building Text-Table Installing /home/parv/test-perl5/lib/perl5/Text/Table.pm Installing /home/parv/test-perl5/man/man3/Text::Table.3

Replies are listed 'Best First'.
Re: cpan client- install_base value not used to install Text::Table
by haukex (Archbishop) on Sep 12, 2019 at 17:58 UTC

    I'd suggest using local::lib, as that will take care of configuring the modules in a way that they should install cleanly to a local directory. Both cpan and cpanm can make use of local::lib; I believe the former requires a bit of configuration (modern versions should ask you whether you want to use local::lib on initial configuration), and cpanm doesn't need any extra configuration; I'd recommend the latter.

    Of course, you could just install an entire build of Perl locally using perlbrew.

Re: cpan client- install_base value not used to install Text::Table
by Haarg (Priest) on Oct 15, 2019 at 10:26 UTC

    Others have mentioned that PREFIX and --install_base work differently, and you probably don't want to combine them. You should probably change PREFIX to INSTALL_BASE.

    The direct problem you are having is because you've configured the --install_base option on the mbuild_arg, which is the build step. It needs to be set either on the install step (mbuild_install_arg) or the configure step (mbuildpl_arg). Setting it on mbuildpl_arg would correspond to how you were using the option manually.

    I would definitely recommend using local::lib instead of configuring this in your CPAN shell. And if you didn't want to use local::lib, you would be better off using the PERL_MM_OPT and PERL_MB_OPT environment variables to change the installation location. Either local::lib or using the environment variables manually has the advantage of working with any install tool, not just the CPAN shell.

      Thanks for explaining the details, especially about "mbuild_install_arg" option.

Re: cpan client- install_base value not used to install Text::Table
by Anonymous Monk on Sep 14, 2019 at 17:19 UTC

      One thing to note that module installs as expected when doing everything with Module::Build (./Build, etc) manually (second example). But fails when installing via cpan.

      I understand that "install_base" (Module::Build) is not same as PREFIX (ExtUtils::MakeMaker).

      Are you suggesting that cpan uses Module::Build to build the module but then uses ExtUtils::MakeMaker to install it (depending on value of INSTALL_BASE) even though "MB" is "prefer_installer" in the CPAN configuration?

        I am suggesting maybe edit config to not use prefix and see what happens. The manual command shown doesn't match the automatic one.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11106074]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-19 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found