Closed rwp0 closed 8 months ago
Seems like we need to use the -g
option of the install
command as documented in the SYNOPSIS (accessible with cpm --help
)
# install module into current @INC instead of local/
> cpm install -g Module
Else the modules are being installed under the ~/local
directory instead of under the ~/perl5
directory since the Perlbrew Perl looks at ~/perl5/perlbrew/perls/<PERL-NAME>/lib/site_perl/<PERL-VERSION>/
for third-party CPAN modules.
I think this could be documented somewhere in the README or elsewhere so that the users won't get confused.
You could also indicate the local
directory explicitly:
perl -Ilocal -MURI
@rwp0
Thanks @smonff good to know.
I think it's better to indicate the full path here:
perl -I$HOME/local -MURI
It seems to me that cpm
differs from cpan
and cpanm
by always using local::lib
and thereby installing to local
by default.
Yes, but local
is not necessarily in the user's home. In my case, it's usually in the project's root directory during development. It may differ during deployment, where an absolute path might be useful.
It helps to keep each projects dependencies isolated, like npm
and node_modules
in the Nodejs world.
It helps to keep each projects dependencies isolated, like npm and node_modules in the Nodejs world.
I don't understand this part.
How installing the modules in a central ~/local
directory keeps them isolated per project (since each project is supposed to have its own directory)?
If you don't use the -g
flag, it install dependencies to the current location.
If you don't use the
-g
flag, it install dependencies to the current location.
Oh yeah now I understand it
mkdir project
cd project
cpm install Path::Tiny
less ./local/lib/perl5/Path/Tiny.pm
Like npm install
does.
Thanks a lot! 🙂
I can install and use modules after doing
install-cpanm
:But I cannot
use
(import) modules after doinginstall-cpm
successfully:I'd prefer
cpm
tocpanm
because of its non-verbosity and colors, but what am I doing wrong?Do I need to do additional configuration manually after issuing the
install-cpanm
command for thecpm
utility to install modules to usual paths or be the same ascpanm
?Not very familiar with it, and thinking perhaps I need to do some tweaks for
cpm
for the brewedperl
to recognize the modules (if that's not done by default byperlbrew
after doinginstall-cpm
).Thanks