I'm working on a project that requires all third-party (read: CPAN) perl modules to be installed in a perforce repository, so that any code that depends on them can be successfully run without anyone else needing to manually install them. I ran into an issue though when trying to install XML::Parser. I use cpanminus to install my CPAN modules, so I ran cpanm -L . XML::Parser
in the desired directory (this has worked before with other modules) and got the error:
Expat.xs:12:19: error: expat.h: No such file or directory
I'm used to using Ubuntu and apt-get, but at work I have to use RedHat and I'm not sure how to install expat to a local directory. I ran yum search expat
and got
expat.i386 : A library for parsing XML.
expat.x86_64 : A library for parsing XML.
So I tried yum install --installroot=. expat.i386
and got the following errors:
Loaded plugins: rhnplugin, security
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in ./var/lib/rpm
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in ?
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 309, in user_main
errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 157, in main
base.getOptionsConfig(args)
File "/usr/share/yum-cli/cli.py", line 187, in getOptionsConfig
self.conf
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 665, in <lambda>
conf = property(fget=lambda self: self._getConfig(),
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 240, in _getConfig
self._conf = config.readMainConfig(startupconf)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 804, in readMainConfig
yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 877, in _getsysver
idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed
What am I doing wrong? Also, once I do get expat installed, I'm not sure how I would tell cpanm where to find it.
I see a couple of things that could help get you on the right path. First, the package you want is called expat-devel
. Also, I think you need to provide an absolute path to the --installroot option, and you probably don't need to provide the package extension to yum unless this is relevant to how you building these modules (i.e., you can usually just do yum install expat-devel
).
It also looks like something may be wrong with your rpmdb, since you got the "rpmdb open failed" message. You can run yum check
to look for problems in rpmdb, but beyond that I can't say anything specifically going on with the package manager. Perhaps others can help more with that aspect.
just install expat by downloading it from http://sourceforge.net/projects/expat/ and $ ./config $ make $ make install
Well, I found a workaround. I installed XML::Simple instead. At first it looked like XML::Simple required XML::Parser, but after some looking found out that it requires either XML::Parser OR XML::SAX, so I installed XML::SAX instead and got XML::Simple working. Good enough for my needs.
来源:https://stackoverflow.com/questions/15484620/installing-xmlparser-requires-expat-h