How do you install perl modules on linux and mac platforms on Travis CI when the language is not set to perl? I'm compiling a C program with perl test scripts.
If the language is perl, cpanm
is available:
cpanm JSON
Otherwise if the platform is linux:
sudo apt-get install libjson-pp-perl
But when on mac cpanm
and apt-get
are not available. The mac platform has the brew
command available to install programs but I can't figure out if I need to install a fresh version of perl instead of just a module for the system perl version.
The mac version also has the cpan JSON
command available, but it hangs to go through an interactive first-run configuration.
Thanks to @simbabque's comment I installed cpanm to the system perl, then used cpanm to install the perl module and it works:
curl -L https://cpanmin.us | sudo perl - --sudo App::cpanminus
sudo cpanm JSON
I've not yet figured out the easiest way to install locally without using sudo.
Edit: Without requiring sudo, using local::lib
to setup $PERL5LIB
paths etc.:
# Install modules into ~/perl5 using system perl
curl -L https://cpanmin.us | perl - App::cpanminus
~/perl5/bin/cpanm local::lib
~/perl5/bin/cpanm JSON
# Add path to ~/perl5 modules to ~/.bashrc
echo '[ $SHLVL -eq 1 ] && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bashrc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.