简体   繁体   中英

Can't install XML::Simple on Perlbrew

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 , eg 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

PS expat 2.2.5 is out

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM