Installing Perl modules on Ubuntu 16.04 - perl

I'm trying to install Perl modules Geo::ShapeFile and Math::Round but I keep coming across the same error and I can't find a solution that works. I've local::lib installed fine but its not being found or something? Am I doing it in the wrong place?
cian#cian-Aspire-5750:~/Documents/Math-Round-0.07$ make install
Manifying 1 pod document
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/man/man3'
mkdir /usr/local/man/man3: Permission denied at /usr/share/perl/5.22/ExtUtils/Install.pm line 477.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1.
Makefile:697: recipe for target 'pure_site_install' failed
make: *** [pure_site_install] Error 13
I notice in my directory '/usr/local/man' points to 'usr/share/man'. I dunno if this was an issue how to solve it. Thanks.

I've local::lib installed fine
No, you don't. The environment has clearly not by set by local::lib. Make sure the following in your login script:
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
(Adjust the path to local::lib if needed.)
Log out and log back in or use the following to pick up the changes:
exec bash -l

If you want to install module systemwide (it's what you do), you should have root privileges. Try sudo make install or install modules locally.

Alternatively you may try a cpanm client, which handles local::lib installs either:
$ cpanm -l ~/ Geo::ShapeFile Math::Round
And then don't forget to adjust perl5lib var to see installed modules:
$ PERL5LIB=~/lib/perl5

Related

Perl not recognizing module / module path for root user

I am new to Perl so please bear with me. Thank you for your assistance.
I have an Ubuntu machine with Perl on it. I followed the local::lib bootstrapping guide
I used cpanm to install DBI and other modules to my system. I am concerned there may be other DBI modules available on my system which could be part of the problem. This is the result of find / -name 'DBI.pm' 2>/dev/null:
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/blib/lib/DBI.pm
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/blib/lib/Bundle/DBI.pm
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/DBI.pm
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/lib/Bundle/DBI.pm
/home/ubuntu/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/DBI.pm
/home/ubuntu/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/Bundle/DBI.pm
I added 2 lines to my .bashrc file. (I added the second line because I broke things for the non-root user and this fixed it; maybe I broke something with local::lib?)
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
PERL5LIB="/home/ubuntu/perl5/lib/perl5"
I can run my perl script as a non-root user.
If I run with sudo perlScript.pl I get this error: Can't locate DBI.pm in #INC (you may need to install the DBI module)
I have been troubleshooting #INC for a while now and cannot figure out how to adjust it for the root user. I have tried various things including adding PERL5LIB to .profile and calling my script like so: sudo sh -c '. ~/.profile; perl ~/perlScripts/perlScript.pl "argForScript"' (I verified that PERL5LIB is being set with sudo sh -c '. ~/.profile; echo $PERL5LIB')
However I always get the #INC error. The most obvious thing I have noticed is comparing sudo perl -V and perl -V. The sudo call does not show any ENV vars and the #INC does not include the desired PERL5LIB location. The non-sudo call does show the desired ENV and #INC vars.
I am considering wiping things and doing a fresh install with root privileges for local::lib and cpan. Not really sure what else to try at this point.
These are the commands that ended up working for me. I corrupted my first environment with local::lib / non-sudo cpan install, so I setup a fresh VM.
sudo apt install make
sudo apt install build-essential
sudo apt install libmysqlclient-dev
sudo cpan App::cpanminus
cpanm --sudo DBI
cpanm --sudo Array::Utils
cpanm --sudo DBD::mysql

Ocamlfind command not found

I'm running into an issue installing a package that's reliant on ocamlfind but I'm getting an ocamlfind: command not found error when making.
I have installed ocamlfind with the ocaml package manager and have tried reinstalling using "opam reinstall ocamlfind".
I have also tried the 'eval opam config env' command to see if updates my bin.
Has anyone run into a similar issue/know what this might be caused by
The output when running the make:
make
ocamlfind ocamlc -pp "camlp4o -I lib/dcg -I lib/ipp pa_dcg.cmo pa_ipp.cmo" -w usy -thread -I lib -I lib/dcg -I lib/ipp -c semantics.ml
/bin/sh: ocamlfind: command not found
The output when trying ocamlfind
ocamlfind
-bash: ocamlfind: command not found
ocaml is installed
opam install ocamlfind
[NOTE] Package ocamlfind is already installed (current version is 1.5.5).
and when running the eval command
eval 'opam config env'
CAML_LD_LIBRARY_PATH="/home/centos/.opam/system/lib/stublibs:/usr/lib64/ocaml/stub libs"; export CAML_LD_LIBRARY_PATH;
MANPATH="/home/centos/.opam/system/man:"; export MANPATH;
PERL5LIB="/home/centos/.opam/system/lib/perl5"; export PERL5LIB;
OCAML_TOPLEVEL_PATH="/home/centos/.opam/system/lib/toplevel"; export OCAML_TOPLEVEL_PATH;
PATH="/home/centos/.opam/system/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin"; export PATH;
I'm on a server running centos 7
This command
eval 'opam config env'
is almost assuredly a typo and was supposed to be
eval `opam config env`
though using $(...) instead is the modern equivalent and avoids this font-fact confusion
eval $(opam config env)
That being said that just sets the environment variables in the current shell session (and exports them for use by processes run by this shell session).
As such that needs to be run in every shell session that needs those set (including each line of the makefile that expects them to be set if the environment that runs make doesn't already have them set and exported).
try
sudo apt-get install ocaml-findlib

how to avoid cpanm stopping installation waiting for a prompt that is shown only in Build.log

Instaling PGPLOT the install gets stopped for ever here:
$ cpanm PGPLOT
--> Working on PGPLOT
Fetching http://www.cpan.org/authors/id/K/KG/KGB/PGPLOT-2.21.tar.gz ... OK
Configuring PGPLOT-2.21 ... OK
Building and testing PGPLOT-2.21 ...
Looking at the Build.log seems that it is waiting for a prompt answer
$ tail ~/.cpanm/build.log
-L/usr/lib -L/usr/local/lib -lcpgplot -lpgplot -lX11 -lpng -L/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/usr/lib -lgfortran -lm \
chmod 755 blib/arch/auto/PGPLOT/PGPLOT.so
cp PGPLOT.bs blib/arch/auto/PGPLOT/PGPLOT.bs
chmod 644 blib/arch/auto/PGPLOT/PGPLOT.bs
Manifying blib/man3/PGPLOT.3
make: warning: Clock skew detected. Your build may be incomplete.
make: Warning: File `Makefile' has modification time 3e+02 s in the future
PERL_DL_NONLAZY=1 /home/pmg/perl5/perlbrew/perls/perl-5.16.0/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
Default Device for plot tests [recommend /XSERVE] ?
How can I avoid this question either forcing defaults or given the option through env. vars?
[UPDATE] FIX
From the Russell answer I exported the variable for device
export PGPLOT_DEV=/XSERVE; cpanm PGPLOT
And connected with x11vnc to the server (to the main display) for closing all windows the pgplot test was displaying.
[NOTE] don't try to install pgplot perl lib under screen even with ssh -X, chances are that you are not in the same computer you starter your original screen and the X redirection will not work. You can circumvent that limitation with a vnc connection to main display or you will not being able to finish the installation. xrdp and other vnc that open a new session will not work. You need to share the main display.
From reading test.pl in the distribution, it checks the PGPLOT_DEV environment variable. It looks like the valid values are /XSERVE for Unix/Linux and /PNG for Windows.

Need help installing Spreadsheet::ParseExcel

I am trying to install Spreadsheet::ParseExcel to use with ExcelLatex. This is what I did:
Installed Active perl, Then install CPAN.pm by perl -MCPAN -e shell
I was asked for configuration and mirror site and I let perl do the auoconfoguration. At the end I got the following message: Autoconfiguration complete.Then I tried:
perl -MCPAN -e 'install "Spreadsheet::WriteExcel"'
And it tried to install it but at the end I got the following error:
ERROR: Can't create '/Library/Perl/5.12/Spreadsheet'
mkdir /Library/Perl/5.12/Spreadsheet: Permission denied at /System/Library/Perl/5.12/ExtUtils/Install.pm line 494
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
JMCNAMARA/Spreadsheet-WriteExcel-2.37.tar.gz
/usr/bin/make install -- NOT OK
I really appreciate it one please help me how I can solve the problem
It is trying to create a directory in the root (mkdir /Library/Perl/5.12/Spreadsheet)
You have to be root to be able to do that.
You may could use PerlBrew or local::lib to install your perl libs into your home dir.
# Install Spreadsheet::WriteExcel and its missing dependencies to the '~/perl5' directory
perl -MCPAN -Mlocal::lib -e 'CPAN::install(Spreadsheet::WriteExcel)'
# Just print out useful shell commands
$ perl -Mlocal::lib
export PERL_MB_OPT='--install_base /home/username/perl5'
export PERL_MM_OPT='INSTALL_BASE=/home/username/perl5'
export PERL5LIB='/home/username/perl5/lib/perl5/i386-linux:/home/username/perl5/lib/perl5'
export PATH="/home/username/perl5/bin:$PATH"
#create a environment setting script and execute it.
perl -Mlocal::lib > ~/.setenv && . ~/.setenv
Regards,

What's the recommended way to use a non-system perl for a web app?

I want to run a Catalyst application on my web server, which has system perl v5.10. I want to use at least v5.12 for the app., and I don't want to meddle with the system perl.
Our sysadmin insists that the app. be run by a non-shell user (such as "nobody")
I know I can use perlbrew to use non-system perl for development, but I'm not sure what the best way to then run the live version is. How do people advise handling this situation?
Since you're familiar with perlbrew, you could still use that to install Perl.
perlbrew install 5.16.1 --as=5.16.1t -Dusethreads
You just make sure you give proper permissions. Say your $PERLBREW_ROOT is /home/djh/perl5/perlbrew (the default):
chmod a+x /home/djh/
chmod a+x /home/djh/perl5/
chmod a+x /home/djh/perl5/perlbrew/
chmod a+x /home/djh/perl5/perlbrew/perls/
chmod -R a+rX /home/djh/perl5/perlbrew/perls/5.16.1t/ # Capital "X"!!!
Then use the following shebang line in your script:
#!/home/djh/perl5/perlbrew/perls/5.16.1t/bin/perl
But maybe you don't want it in your home. If so, this is what you can do:
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/R/RJ/RJBS/perl-5.16.1.tar.bz2
tar xvjf perl-5.16.1.tar.bz2
cd perl-5.16.1
sh Configure -des -Dprefix=/opt/perls/5.16.1t -Dusethreads
make test
sudo mkdir /opt/perls/5.16.1t
sudo chown djh:djh /opt/perls/5.16.1t
make install
The installer will setup the permissions correctly. All you have to do is set the shebang to
#!/opt/perls/5.16.1t/bin/perl
("t" is my convention for threaded builds. Remove -Dusethreads if you don't want thread support.)
Give nobody (i.e., everybody) read and execute permission to the perl executable(s) and all libraries (everything under the #INC directories).
Change the shebang line in all your applications scripts (including at least everything under your ./scripts directory) to the instance of perl that you want to use. Or if you want to be flexible about out, point the shebang line to a symbolic link that points to a desired perl executable. Make sure this link is also accessible to nobody.
Restart your application whenever you point your symbolic link to a different version of Perl.