【发布时间】:2019-01-06 06:54:55
【问题描述】:
我正在尝试在 Perlbrew 下安装 XML::Simple,但遇到了一个似乎需要 root 访问权限才能修复的错误。但是,使用 perlbrew(或至少其中之一)的全部目的是使您的 perl 环境与操作系统安装的 perl 版本分离。
我已经安装了 perlbrew(5.10.1,遗留代码要求)和几个模块。它目前正在按预期运行。但是,尝试安装 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.
$
这是日志文件的输出(切到相关部分):
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.
~
我尝试通过以下方式在本地安装 expat:
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
我已验证 expat.h 位于 ~/perl5/perlbrew/perls/perl-5.10.1/include 中。我更新了路径以包含该位置。
我看到的每个修复都是通过操作系统工具安装 expat(适用于各种风格)。
问题是我没有 root 访问权限,虽然我可以在技术上要求管理员安装它,但我的项目需要一个不需要 root 访问权限的解决方案,因为它将通过多个环境和服务器复制。
有没有办法在没有 expat 的情况下安装 XML::Simple?或者一种在 perlbrew 中安装 expat 以便 XML::Simple 可以找到并使用它的方法?
【问题讨论】:
-
我试过了,但那个解决方案对我不起作用。我安装了 XML::SAX,但仍然出现错误。 $ cpanm XML::SAX XML::SAX 是最新的。 (1.00) $ cpanm XML::Simple
安装 XML::Parser 失败。有关详细信息,请参阅 /home/user1/.cpanm/work/1532925534.21007/build.log。使用 --force 重试以强制安装它。 !安装依赖项失败:未安装模块“XML::Parser”!拯救 XML-SAX-Expat-0.51 的安装。 !安装依赖项失败:未安装模块“XML::SAX::Expat”!拯救 XML-Simple-2.25 的安装。 -
要安装 XML::Parser,你需要安装 expat 库,以及 expat 库的头文件
-
您真的要安装 XML::Simple 吗?它真的不像它的名字所暗示的那么简单,甚至文档discourages its use。
-
@Dave:确实。
XML::Simplistic或XML::Naive可能更合适!