tokuhirom / plenv

Perl binary manager
Other
512 stars 70 forks source link

No problem to install-cpanm, but failed to find cpanm command #175

Closed yong9900 closed 2 years ago

yong9900 commented 2 years ago

on RedHat 7:

[mzhao@mzhao ~]$ plenv global
5.34.0
[mzhao@mzhao ~]$ plenv install-cpanm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  295k  100  295k    0     0  11.4M      0 --:--:-- --:--:-- --:--:-- 11.5M
App::cpanminus is up to date. (1.7044)
[mzhao@mzhao ~]$ plenv which cpanm
plenv: cpanm: command not found
[mzhao@mzhao ~]$ plenv rehash
[mzhao@mzhao ~]$ plenv which cpanm
plenv: cpanm: command not found

under my home directory, .cpanm is created, the log file created there mentioned "App::cpanminus is up to date. (1.7044)"

Any hint why?

yong9900 commented 2 years ago

Sorry, looks this is due to my shell env variables, the problem is solved once I did following:

[mzhao@mzhao bin]$ unset PERL5LIB PERL_LOCAL_LIB_ROOT PERL_MB_OPT PERL_MM_OPT
Grinnz commented 2 years ago

A better way to unset those properly is to deactivate your local::lib (eval $(perl -Mlocal::lib=--deactivate-all)) and ensure your shell profile is not activating one. user-wide local::lib is not compatible with plenv, you must use https://github.com/miyagawa/plenv-contrib to manage local::lib within a perl.

On redhat the local::lib may be activated by the presence of the package perl-homedir. You can remove this package or disable it for your user.

yong9900 commented 2 years ago

Hi @Grinnz Thanks for the information. I am a newbie on Perl, not quite understand the effect of local::lib. I need to use the system Perl from time to time on my workstation to do some old stuff (the Perl variables was set up for it), but at the same time, I want to use plenv for my new project. I guess I will just set/unset perl variables when working on different projects?

Grinnz commented 2 years ago

You can create a plenv compatible local::lib for the system perl with plenv-contrib, though it doesn't work quite right and you have to plenv shell system before plenv use system@locallibname works correctly - this spawns a subshell with this local::lib active.

Grinnz commented 2 years ago

Otherwise you can use local::lib itself to activate and deactivate as shown in the local::lib docs rather than manually setting vars. But be careful to only activate it when plenv is set to system perl.

yong9900 commented 2 years ago

@Grinnz Thanks for the explanation. I like your last comment, it becomes simple to use my plenv or system Perl. Thanks!