Can't install XML::Simple on Perlbrew - perl

I'm trying to install XML::Simple under Perlbrew but am hitting an error that seems like it requires root access to fix. However, the whole purpose of using perlbrew (or one of them, at least) is to disassociate your perl environment from the OS installed perl version.
I've installed perlbrew (5.10.1, legacy code requirement) and several modules. It is currently functioning as expected. However, I get an error when trying to install XML::Simple.
$ cpanm XML::Simple
--> Working on XML::Simple
Fetching http://www.cpan.org/authors/id/G/GR/GRANTM/XML-Simple-2.25.tar.gz ... OK
Configuring XML-Simple-2.25 ... OK
==> Found dependencies: XML::SAX::Expat
--> Working on XML::SAX::Expat
Fetching http://www.cpan.org/authors/id/B/BJ/BJOERN/XML-SAX-Expat-0.51.tar.gz ... OK
Configuring XML-SAX-Expat-0.51 ... OK
==> Found dependencies: XML::Parser
--> Working on XML::Parser
Fetching http://www.cpan.org/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gz ... OK
Configuring XML-Parser-2.44 ... OK
Building and testing XML-Parser-2.44 ... FAIL
! Installing XML::Parser failed. See /home/user1/.cpanm/work/1532923694.18203/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Module 'XML::Parser' is not installed
! Bailing out the installation for XML-SAX-Expat-0.51.
! Installing the dependencies failed: Module 'XML::SAX::Expat' is not installed
! Bailing out the installation for XML-Simple-2.25.
$
Here's the output of the log file (cut down to the pertinent part):
cp Expat.pm ../blib/lib/XML/Parser/Expat.pm
Running Mkbootstrap for Expat ()
chmod 644 "Expat.bs"
"/home/user1/perl5/perlbrew/perls/perl-5.10.1/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Expat.bs ../blib/arch/auto/XML/Parser/Expat/Expat.bs 644
"/home/user1/perl5/perlbrew/perls/perl-5.10.1/bin/perl" "/home/user1/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/ExtUtils/xsubpp" -noprototypes -typemap '/home/user1/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/ExtUtils/typemap' -typemap /home/user1/.cpanm/work/1532923694.18203/XML-Parser-2.44/Expat/typemap' Expat.xs > Expat.xsc
mv Expat.xsc Expat.c
cc -c -m32 -march=i686 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"2.44\" -DXS_VERSION=\"2.44\" -fPIC "-I/home/user1/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/x86_64-linux/CORE" Expat.c
Expat.xs:12:19: fatal error: expat.h: No such file or directory
#include <expat.h>
^
compilation terminated.
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory `/home/user1/.cpanm/work/1532923694.18203/XML-Parser-2.44/Expat'
make: *** [subdirs] Error 2
-> FAIL Installing XML::Parser failed. See /home/user1/.cpanm/work/1532923694.18203/build.log for details. Retry with --force to force install it.
-> FAIL Installing the dependencies failed: Module 'XML::Parser' is not installed
-> FAIL Bailing out the installation for XML-SAX-Expat-0.51.
-> FAIL Installing the dependencies failed: Module 'XML::SAX::Expat' is not installed
-> FAIL Bailing out the installation for XML-Simple-2.25.
~
I have tried installing expat locally via:
wget https://sourceforge.net/projects/expat/files/expat/2.2.4/expat-2.2.4.tar.bz2
tar xjf expat-2.2.4.tar.bz2
cd expat-2.2.4
./configure --prefix=/home/user1/perl5/perlbrew/perls/perl-5.10.1/
make
make install
I've verified that expat.h is in ~/perl5/perlbrew/perls/perl-5.10.1/include. I updated my path to include that location.
Every fix I see is to install expat via the operating system tools (for the various flavors).
The issue is that I don't have root access and while I can technically ask the admin to install it, my project requires a solution that doesn't require root access as it will be copied through multiple environments and servers.
Is there a way to install XML::Simple without expat? Or a way to install expat in perlbrew such that XML::Simple will find it and use it?

Install XML::Parser manually and tell ExtUtils::MakeMaker where to find the C libraries. See INC and LIBS.
cpanm --look XML::Parser
PERLPREFIX=/home/user1/perl5/perlbrew/perls/perl-5.10.1/
perl Makefile.PL INC=-I$PERLPREFIX/include LIBS=-L$PERLPREFIX/lib
make && make test && make install
If you use cpan instead of cpanm, you can make this hands-off and permanent. Set the option makepl_arg, e.g. by running at the CPAN shell prompt):
o conf makepl_arg "INC=-I/home/user1/perl5/perlbrew/perls/perl-5.10.1/include LIBS=-L/home/user1/perl5/perlbrew/perls/perl-5.10.1/lib"
o conf commit
P.S. expat 2.2.5 is out

Related

Installing some Module ------- Build.PL --installdirs site -- NOT OK [duplicate]

I'm trying to figure out why I can't get the GD perl module to install on my Debian 7 server. Here is how I installed the core stuff:
sudo apt-get install libgd-gd2-perl
Then running the -MCPAN to install, I get:
root#myserver:~# sudo perl -MCPAN -e 'install GD'
Going to read '/root/.cpan/Metadata'
Database was generated on Sun, 19 Jul 2015 21:41:02 GMT
Running install for module 'GD'
Running make for L/LD/LDS/GD-2.56.tar.gz
Checksum for /root/.cpan/sources/authors/id/L/LD/LDS/GD-2.56.tar.gz ok
CPAN.pm: Going to build L/LD/LDS/GD-2.56.tar.gz
Configuring for libgd version 2.0.36.
Checking for stray libgd header files...none found.
Unknown option: installdirs
Usage: perl Build.PL [options]
Configure GD module.
Options:
-options "JPEG,FT,PNG,GIF,XPM,ANIMGIF" feature options, separated by commas
-lib_gd_path path path to libgd
-lib_ft_path path path to Freetype library
-lib_png_path path path to libpng
-lib_jpeg_path path path to libjpeg
-lib_xpm_path path path to libxpm
-lib_zlib_path path path to libpng
-ignore_missing_gd Ignore missing or old libgd installations and try to compile anyway
If no options are passed on the command line. The program will
attempt to autoconfigure itself with the gdlib-config program (present
in GD versions 2.0.27 or later). Otherwise it will prompt for these
values interactively.
Warning: No success on command[/usr/bin/perl Build.PL --installdirs site]
LDS/GD-2.56.tar.gz
/usr/bin/perl Build.PL --installdirs site -- NOT OK
Running Build test
Make had some problems, won't test
Running Build install
Make had some problems, won't install
Could not read metadata file. Falling back to other methods to determine prerequisites
I've done a load of googling, but nothing seems to fix it. Any suggestions?
The error you are getting is
Unknown option: installdirs
Usage: perl Build.PL [options]
cpan expects Build.PL to pass its arguments to Module::Build, but GD has a funky Build.PL. Let's "fix" it.
Execute the following from a temporary directory:
wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.56.tar.gz
-or-
curl -L http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.56.tar.gz >GD-2.56.tar.gz
tar xvzf GD-2.56.tar.gz
cd GD-2.56
perl -i~ -pE'say "Getopt::Long::Configure(qw( pass_through ));" if /GetOptions/;' Build.PL
/usr/bin/perl Build.PL --installdirs site
sudo ./Build.PL installdeps
./Build.PL make
./Build.PL test
sudo ./Build.PL install
In Ubuntu 15.04, a slight modification of the above intelligent answer seemed necessary in order to get it to install GD. This worked so that the 'cpan' program could then install GD then e.g. Image::Resize (which uses GD) afterwards. I did it after
sudo -i
in a Terminal, and after 'cd' into a temporary folder. Whether of value or not, I first did
apt-get install libgd-dev
Then this, which may contain one or more redundant lines, but it works:
wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.56.tar.gz
tar xvzf GD-2.56.tar.gz
cd GD*
perl -i~ -pE'say "Getopt::Long::Configure(qw( pass_through ));" if /GetOptions/;' Build.PL
/usr/bin/perl Build.PL --installdirs site
chmod 755 Build.PL
./Build.PL installdeps
./Build installdeps
./Build test
./Build install

How to reinstall: re-run module installation for a failed install in Perl's MCPAN?

I'm tried to install XML::LibXSLT, and it failed:
$ sudo perl -MCPAN -e shell
...
cpan[9]> notest install XML::LibXSLT
Running install for module 'XML::LibXSLT'
...
Configuring S/SH/SHLOMIF/XML-LibXSLT-1.94.tar.gz with Makefile.PL
running xslt-config... failed
using fallback values for LIBS and INC
options:
LIBS='-L/usr/local/lib -L/usr/lib -lxslt -lxml2 -lz -lm'
INC='-I/usr/local/include -I/usr/include'
If this is wrong, Re-run as:
$ /usr/bin/perl Makefile.PL LIBS='-L/path/to/lib' INC='-I/path/to/include'
looking for -lxslt... no
libxslt not found
Try setting LIBS and INC values on the command line
Or get libxslt and libxml2 from
http://www.libxml.org/
If you install via RPMs, make sure you also install the -devel
RPMs, as this is where the headers (.h files) are.
No 'Makefile' created SHLOMIF/XML-LibXSLT-1.94.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
Failed during this command:
SHLOMIF/XML-LibXSLT-1.94.tar.gz : writemakefile NO -- No 'Makefile' created
I didn't exit the MCPAN shell; I tried installing sudo apt-get install libxslt1-dev from another terminal, and I wanted to re-run the module installation process. Turns out I can't (I got the clean from perlmonks.org: how to re-run Makefile.PL under CPAN?):
cpan[10]> notest install XML::LibXSLT
Running install for module 'XML::LibXSLT'
SHLOMIF/XML-LibXSLT-1.94.tar.gz
Has already been unwrapped into directory /root/.cpan/build/XML-LibXSLT-1.94-2qijzZ
SHLOMIF/XML-LibXSLT-1.94.tar.gz
No 'Makefile' created
, not re-running
cpan[11]> clean XML::LibXSLT
Running clean for module 'XML::LibXSLT'
Running make clean
No Makefile, don't know how to 'make clean'
cpan[13]> notest install XML::LibXSLT
Running install for module 'XML::LibXSLT'
SHLOMIF/XML-LibXSLT-1.94.tar.gz
Has already been unwrapped into directory /root/.cpan/build/XML-LibXSLT-1.94-2qijzZ
SHLOMIF/XML-LibXSLT-1.94.tar.gz
No 'Makefile' created
, not re-running
Ok, so how do I repeat the installation of this module, now that it failed, and cannot be cleaned either?
Ok, the first thing is to note that there is no (default) way to remove modules from CPAN, failed or not:
How can I de-install a Perl module installed via `cpan`?
That being said, what worked for me was:
exit the MCPAN shell
enter again via sudo perl -MCPAN -e shell
Do not issue install XML::LibXSLT - instead just issue make XML::LibXSLT; note that at this point, I got:
cpan[1]> make XML::LibXSLT
CPAN: Storable loaded ok (v2.30)
Reading '/root/.cpan/Metadata'
Database was generated on Thu, 12 Feb 2015 08:41:02 GMT
Running make for module 'XML::LibXSLT'
...
Scanning cache /root/.cpan/build for sizes
................................................----------------------------DONE
DEL(1/122): /root/.cpan/build/JSON-DWIW-0.47-ppRqJq
CPAN: YAML loaded ok (v0.73)
DEL(2/122): /root/.cpan/build/JSON-DWIW-0.47-ppRqJq.yml
DEL(3/122): /root/.cpan/build/common-sense-3.4-bfJ9E8
...
Have no idea where these deletions came from.
At this point, the command concluded with:
...
/usr/bin/ld: cannot find -lgdbm
/usr/bin/ld: cannot find -lgdbm_compat
collect2: ld returned 1 exit status
...
Failed during this command:
SHLOMIF/XML-LibXSLT-1.94.tar.gz : make NO
cpan[2]> make XML::LibXSLT
Running make for module 'XML::LibXSLT'
SHLOMIF/XML-LibXSLT-1.94.tar.gz
Has already been unwrapped into directory /root/.cpan/build/XML-LibXSLT-1.94-4kLOVB
SHLOMIF/XML-LibXSLT-1.94.tar.gz
Has already been prepared
SHLOMIF/XML-LibXSLT-1.94.tar.gz
Could not make: Unknown error
... and after this, for reasons unknown to me, the clean command started responding:
cpan[4]> clean XML::LibXSLT
Running clean for module 'XML::LibXSLT'
Running make clean
rm -f \
*.a core \
core.[0-9] blib/arch/auto/XML/LibXSLT/extralibs.all \
...
mv Makefile Makefile.old > /dev/null 2>&1
SHLOMIF/XML-LibXSLT-1.94.tar.gz
/usr/bin/make clean -- OK
... and after doing in another terminal sudo apt-get install libgdbm-dev, and a couple more clean XML::LibXSLT and make XML::LibXSLT, finally got the module to install:
cpan[8]> notest install XML::LibXSLT
Running install for module 'XML::LibXSLT'
SHLOMIF/XML-LibXSLT-1.94.tar.gz
...
Installing /usr/local/man/man3/XML::LibXSLT.3pm
Appending installation info to /usr/lib/perl/5.10/perllocal.pod
SHLOMIF/XML-LibXSLT-1.94.tar.gz
/usr/bin/make install -- OK
Well, hope this helps someone; cheers!

XML::Parser refusing to install

I've been trying to install XML::Simple on Ubuntu 12.10 for the past two hours or so and have officially run out of ideas. It's failing at the XML::Parser.
I've done an
sudo apt-get install expat
and it still did not work. Here's the error I've been getting:
make[1]: Entering directory `/home/<user>/.cpan/build/XML-Parser-2.41-MCLo7T/Expat'
cp Expat.pm ../blib/lib/XML/Parser/Expat.pm
/usr/bin/perl /usr/share/perl/5.14.2/ExtUtils/xsubpp -noprototypes -typemap /usr/share /perl/5.14/ExtUtils/typemap -typemap typemap Expat.xs > Expat.xsc && mv Expat.xsc Expat.c
cc -c -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"2.41\" -DXS_VERSION=\"2.41\" -fPIC "-I/usr/lib/perl/5.14/CORE" Expat.c
Expat.xs:12:19: fatal error: expat.h: No such file or directory
compilation terminated.
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory `/home/sclarawu/.cpan/build/XML-Parser-2.41-MCLo7T/Expat'
make: *** [subdirs] Error 2
TODDR/XML-Parser-2.41.tar.gz
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
Seems to be telling me that it's unable to find expat.h, but I'm not sure why or how, considering expat is installed? I tried to apt expat-devel, but it appears not to be a package in apt. Any ideas would be greatly appreciated. :)
EDIT: I seemed to have been simply trying to install the wrong package. -.- It's always the little things. Much thanks to those who answered!
Another way to get to the same information which #Moritz Bunkus has pointed out above.
ubuntu:~$ apt-cache search expat
expat - XML parsing C library - example application
libexpat1 - XML parsing C library - runtime library
libexpat1-dev - XML parsing C library - development kit
The third one in the result set is what you are looking for.
Adding to the other answers, here's how to install the expat dependency on CentOS/RHEL:
yum install expat-devel
You need to install the Expat library and its development headers. For DebUbuntu this means libexpat1-dev as well as those distros often split their libraries into two packages: one for the runtime components (shared libraries, data files, general documentation), one for the development components (static libraries, header files, development documentation).
Just in case, using Debian Jessie I had to install libexpat1-dev by executing apt-get install libexpat1-dev
I only managed to install it by downloading it from cpan and manually editing the Makefile.pl inside to correctly pointing to the EXPATLIBPATH and EXPATINCPATH.
See this post for more detailed instructions.

Perl CSV_XS module installation failed using Cygwin

I am having problems installed a CPAN module Text::CSV_XS using Cygwin.
I did a
$ cpan Text::CSV_XS
CPAN: Storable loaded ok (v2.20)
.... Every was good till:.....
Writing Makefile for Text::CSV_XS
cp CSV_XS.pm blib/lib/Text/CSV_XS.pm
/usr/bin/perl.exe /usr/lib/perl5/5.10/ExtUtils/xsubpp -typemap /usr/lib/perl5/5 .10/ExtUtils/typemap CSV_XS.xs > CSV_XS.xsc && mv CSV_XS.xsc CSV_XS.c
gcc-4 -c -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -g3 -fno-strict-aliasing -p ipe -fstack-protector -I/usr/local/include -DUSEIMPORTLIB -O3 -DVERSION=\"0.8 8\" -DXS_VERSION=\"0.88\" "-I/usr/lib/perl5/5.10/i686-cygwin/CORE" CSV_XS.c
/bin/sh: gcc-4: command not found
Makefile:330: recipe for target `CSV_XS.o' failed
make: *** [CSV_XS.o] Error 127
HMBRAND/Text-CSV_XS-0.88.tgz
make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
I installed another module earlier, without problem.
Make is installed
gcc is installed
/bin/sh returns a new shell.
$ /bin/sh
$
Important note: as of this writing, gcc4 is now in the obsolete packages section which is hidden by default in the Cygwin installer.
Fire up the Cygwin packagre manager (setup.exe) and install gcc4. Use the search facility to locate the package in the manager. While you're at it, also install make, autoconf and automake. You'll find all these packages in the devel section.
Then retry, it will succeed, I just tested it:
MiLu#Dago: ~ > cpan Text::CSV_XS
...
Installing /usr/lib/perl5/site_perl/5.10/i686-cygwin/auto/Text/CSV_XS/CSV_XS.bs
Installing /usr/lib/perl5/site_perl/5.10/i686-cygwin/auto/Text/CSV_XS/CSV_XS.dll
Installing /usr/lib/perl5/site_perl/5.10/i686-cygwin/Text/CSV_XS.pm
Installing /usr/share/man/man3/Text.CSV_XS.3pm
Appending installation info to /usr/lib/perl5/5.10/i686-cygwin/perllocal.pod
HMBRAND/Text-CSV_XS-0.88.tgz
/usr/bin/make install -- OK

bugzilla | perl module installation nightmare: no cc, is gcc OK?

I am trying to install Bugzilla. I don't recall it being so difficult. We have a ubuntu server on the cloud, and at first I attempted to install through the rackspace UI. This didn't work, so I ssh'ed in and actually downloaded the tarball to do it the old-fashioned way.
However, it appears there are three perl modules having install problems. I have tried everything I know to get them to install, and am at a loss. I've tried googling for some answers, but I am either not using the correct terminology or this is truly unique to my situation.
The three offending perl modules failing the checksetup.pl:
/usr/bin/perl install-module.pl DateTime
/usr/bin/perl install-module.pl DateTime::TimeZone
/usr/bin/perl install-module.pl Template
When I attempt to install any of them, they fail miserably, apparently because the cc compiler is not installed (see below). When I checked for a cc package under APT, I could only find gcc. Will that be sufficient, and will I need to alias gcc to cc in order for these installs to work?
/usr/bin/perl /usr/local/share/perl/5.10.1/ExtUtils/xsubpp -typemap /usr/share/perl/5.10/ExtUtils/typemap Stash.xs > Stash.xsc && mv Stash.xsc Stash.c
cc -c -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"2.22\" -DXS_VERSION=\"2.22\" -fPIC "-I/usr/lib/perl/5.10/CORE" Stash.c
/bin/sh: cc: not found
make[1]: *** [Stash.o] Error 127
make[1]: Leaving directory `/root/.cpan/build/Template-Toolkit-2.22-xzQg_q/xs'
make: *** [subdirs] Error 2
ABW/Template-Toolkit-2.22.tar.gz
/usr/bin/make -- NOT OK
Skipping test because of notest pragma
Running make install
Make had returned bad status, install seems impossible
You shouldn't compile Perl with one compiler (cc) and then compile modules with another compiler or compiler build (gcc) unless you happen to know their compatible. I find it very hard to believe that Ubuntu provided a Perl built with a compiler they don't provide.
Then there's the issue that you're installing unmanaged modules into a distro-managed Perl. That's... less than ideal.
The simplest solution is probably:
apt-get install \
libdatetime-perl \
libdatetime-timezone-perl \
libtemplate-perl
Another solution is to install a local build of Perl, perhaps using perlbrew.
Personally, I never use the system Perl. It's there for the system's needs first (not mine), and that causes problems. In this case, since the distro does provide the packages you need, it should be fine to just install those packages.
Just Install GCC and then Perl.To install the gcc package in the Debian/Ubuntu Linux distribution, enter the following command in a terminal:
> apt-get install gcc make linux-headers-$(uname -r)
I went ahead and installed the gcc package, and the installs completed. Whew. It has been a long time...