Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing XML::Parser requires expat.h

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.

like image 468
Lorkenpeist Avatar asked Feb 18 '23 03:02

Lorkenpeist


2 Answers

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.

like image 82
SES Avatar answered Feb 19 '23 18:02

SES


just install expat by downloading it from http://sourceforge.net/projects/expat/ and $ ./config $ make $ make install

like image 40
Tomasz Swider Avatar answered Feb 19 '23 19:02

Tomasz Swider