Comments (3)
A workaround for that is to install local::lib and export the environment variables before starting cpan for the first time. I agree that it would be nice if it was easier to do without installing local::lib beforehand.
EDIT: one example of the environment variables is
export PATH="$HOME/.local/share/perl/bin${PATH:+:${PATH}}" export PERL5LIB="$HOME/.local/share/perl/lib/perl5" export PERL_LOCAL_LIB_ROOT="$HOME/.local/share/perl" export PERL_MB_OPT="--install_base '$HOME/.local/share/perl'" export PERL_MM_OPT="INSTALL_BASE=$HOME/.local/share/perl"
This is helpful, but I can't get cpan
to work with such a setup.
I have moved the perl stuff to ${HOME}/.local/share/perl
with the suggested PERL
and PATH
environment variables set.
I run cpan
initially, and it creates ${HOME}/.cpan
. If I block this creation (for example, by creating a read-only ${HOME}/.cpan
file before running cpan
, it exits with
mkdir /Users/bwaters/.cpan: File exists at /System/Library/Perl/5.30/CPAN/HandleConfig.pm line 595.
If I remove that experimental block, it goes through the full setup of cpan. I tell it where it should set things. And indeed, after all there are correct paths in the resulting MyConfig.pm
-- just in the $HOME/.cpan
dirs.
Try again (all commands are run from $HOME):
% rm -rf .cpan
% rm -rf .local/share/{cpan,perl}
% mkdir .local/share/{cpan,perl}
% ln -s .local/share/cpan .cpan
% cpan
And we do another first-time setup, only this time, I specify the cpan_home
, but accept all other defaults. Modules seem to get built. Then we are at a working interactive cpan prompt.
I exit, then remove the vestigial symlink in $HOME/.cpan => $HOME/.local/share/cpan
.
Then run cpan
again. Of course, it has no idea what I'm talking about, and gets set to create the whole thing again in $HOME/.cpan.
I try to get a bit further by specifying my CPAN config that we just created, there's all the right paths there:
% grep cpan_home .local/share/cpan/CPAN/MyConfig.pm
'cpan_home' => q[/Users/bwaters/.local/share/cpan],
CPAN is happy with this. So happy, it claims everything has been done already and we can all go home:
% cpan -j ${HOME}/.local/share/cpan/CPAN/MyConfig.pm
Nothing to install!
I haven't yet found a way to explain $XDG_DATA_HOME
to cpan.
from cpanpm.
PS: Can I customize where
local::lib
dumps its shit? Thatperl5
folder is bogging me...
A workaround for that is to install local::lib and export the environment variables before starting cpan for the first time. I agree that it would be nice if it was easier to do without installing local::lib beforehand.
EDIT: one example of the environment variables is
export PATH="$HOME/.local/share/perl/bin${PATH:+:${PATH}}"
export PERL5LIB="$HOME/.local/share/perl/lib/perl5"
export PERL_LOCAL_LIB_ROOT="$HOME/.local/share/perl"
export PERL_MB_OPT="--install_base '$HOME/.local/share/perl'"
export PERL_MM_OPT="INSTALL_BASE=$HOME/.local/share/perl"
from cpanpm.
% cpan -j ${HOME}/.local/share/cpan/CPAN/MyConfig.pm Nothing to install!I haven't yet found a way to explain
$XDG_DATA_HOME
to cpan.
Got this working.
Make sure that whatever directory you're using for your .cpan
configuration dir is in perl's @INC
path.
Here is a shell init script that I'm using to set environment variables appropriately:
# updated: 2023-12-06 18:49:10
export VERSIONER_PERL_VERSION=5.34
export PERL_LOCAL_LIB_ROOT="${XDG_DATA_HOME}/perl"
export PERL_CPANM_HOME="${PERL_LOCAL_LIB_ROOT}/cpan"
export PERL5LIB="${PERL_CPANM_HOME}:${PERL_LOCAL_LIB_ROOT}/lib/perl5"
export PERL_MB_OPT="--install_base '${PERL_LOCAL_LIB_ROOT}'"
export PERL_MM_OPT=" INSTALL_BASE='${PERL_LOCAL_LIB_ROOT}'"
Note that the environment variable PERL_CPANM_HOME
is a variable used by the perl module App:cpanminus
cpanminus and IS NOT used by mainline CPAN -- but it's a convenient idea so I've used it in my shell script.
Note that (again, for mainline CPAN) you also have to set the absolute path to the .cpan
config dir (whatever name you want not just 'dot-cpan') in your CPAN/MyConfig.pm
file. If you have already configured CPAN and have moved a populated directory (as I did in my previous comment), it may be easiest to just search/replace the text in the config file via your editor or method of choice. Otherwise, you can use the cpan o conf
command in the cpan
shell.
Here is what I get when I have that CPAN/MyConfig.pm
set to correspond to my environment:
❯ cpan
Loading internal logger. Log::Log4perl recommended for better logging
cpan shell -- CPAN exploration and modules installation (v2.28)
Enter 'h' for help.
cpan[1]> o conf | grep local
$CPAN::Config options from /Users/bwaters/.local/share/perl/cpan/CPAN/MyConfig.pm:
build_dir [/Users/bwaters/.local/share/perl/cpan/build]
cpan_home [/Users/bwaters/.local/share/perl/cpan]
histfile [/Users/bwaters/.local/share/perl/cpan/histfile]
keep_source_where [/Users/bwaters/.local/share/perl/cpan/sources]
prefs_dir [/Users/bwaters/.local/share/perl/cpan/prefs]
cpan[2]>
To summarize:
- Initially, run
cpan
and run through the manual init process. There, make sure to setcpan_home
to the directory path of your choice. Exit thecpan
session; your configuration will be written to$HOME/.cpan
(CPAN home path). - Move that
$HOME/.cpan
to the CPAN home path that you chose in Step 1. - Edit the
CPAN/MyConfig.pm
text and replace$HOME/.cpan
with your CPAN home path. - Use a shell init script to set shell environment variables to ensure that the CPAN home path is in
perl
's@INC
path.
(You may see that in my example here, I'm running macOS. Apple ships two versions of Perl with the OS, 5.30 and 5.34. I've chosen to run with the more recent version (which is still out of date); I've set this choice via the VERSIONER_PERL_VERSION
environment variable.)
from cpanpm.
Related Issues (20)
- Configure with only fresh mirrors HOT 5
- Failure to configure cpan: getaddrinfo(ucu.ac.ug,,AF_INET) failed - No address associated with hostname HOT 1
- first time setup on cygwin with strawberry also installed picks up wrong patch executable, leading to an endless loop
- Some questions about the proxy settings for cpan and cpanm.
- Relative dir for local::lib doesn't work
- Not able to create local::lib with non-root user in docker container : fileparse(): need a valid pathname at /usr/share/perl/5.30/CPAN/FirstTime.pm HOT 1
- Can't locate local/lib.pm in @INC : Installation of `App::cpanminus` fails on Windows 11, WSL with Ubuntu 20.04 HOT 2
- the distroprefs "Filenames" chapter documenting "File path" and "Activating the feature" was a frustrating surprise
- RT-145462: cpan -O chokes on some version numbers
- RT-145462: cpan -g exits with the wrong value
- RT-145462: cpan -g should use the same download mechanism as CPAN.pm HOT 2
- RT-145462: cpan -g does not handle paths, such as AUTHOR/Foo-1.0.tar.gz
- RT-145462: cpan -O version columns are too narrow to show full versions
- RT-145462: HTTP status code check in cpan is too inclusive
- RT-145462: cpan(1) log message uses the wrong key HOT 1
- [feature] Shell completion HOT 4
- Current key unsupported in FIPS mode
- fix INSTALLDIRS for newer PERL versions HOT 2
- Add support for static install
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpanpm.