安装ruby gem nokogiri时缺少libxslt

sad*_*ave 13 ruby gem nokogiri libxslt gitlab

我认识到这是一个重复的问题,但是我发现与此问题有关的所有其他答案似乎都没有帮助我......

我正在安装GitLab并运行gem依赖项,当它达到NokoGirigem要求时失败并显示以下信息:

ERROR:  Error installing nokogiri:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
extconf.rb:10:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:10:in `<main>': Use RbConfig instead of obsolete and deprecated Config. 
extconf.rb:11:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc()... -lxml2
checking for xsltParseStylesheetDoc()... -lxslt
-----
libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
Run Code Online (Sandbox Code Playgroud)

因此,此错误导致我尝试libxslt使用以下命令进行安装:

$ sudo apt-get install libxslt-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
libxslt1-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 146 not upgraded.
Run Code Online (Sandbox Code Playgroud)

什么给出了什么?NokoGiri需要这个包,但是已经安装了包!我似乎无法解决这个问题,有什么帮助吗?

Von*_*onC 35

首先确保你拥有所有依赖项,如" 在Ubuntu上使用RVM安装Nokogiri "中所述(其中提到了相同的错误消息)

我不知道为什么它找不到包"libxslt".而不是担心,我将安装Nokogiri GitHub页面上列出的依赖项:

$ sudo apt-get install libxslt-dev libxml2-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
libxslt1-dev is already the newest version.
libxml2-dev is already the newest version.
Run Code Online (Sandbox Code Playgroud)

这似乎运作得很好,所以我按下.下一步是安装实际的Nokogiri宝石.说明使用"sudo gem install nokogiri",但因为我正在使用RVM,我放弃了"sudo"部分:

$ gem install nokogiri
Run Code Online (Sandbox Code Playgroud)

考虑到" 在Ubuntu中全新安装RVM并不让我安装gems(zlib错误) ",因为你有libxslt1-dev(而不是libxslt-dev),你可能会考虑重新编译你的ruby.
(有点像" 如何在Ubuntu 11.10上使用RVM获取IRB中的Readline支持 ")


小智 14

试试Nokogiri 1.6.0.rc1,它将gem中的libxml2和libxslt捆绑在一起.这应该解决您的安装问题:

gem install nokogiri --pre
Run Code Online (Sandbox Code Playgroud)

应该做的伎俩.


小智 10

尝试安装依赖项

sudo apt-get install libxslt-dev libxml2-dev
Run Code Online (Sandbox Code Playgroud)


vji*_*sky 10

也许这会对其他人有所帮助:如果你收到错误:


libxslt is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

你还需要安装libxslt的devel版本 apt-get install libxslt-dev 或CentOS

yum install libxslt-devel