运行Bundle Install时Nokogiri v 1.8.1问题

问题描述 投票:8回答:8

当运行Bundle Install或Gem Install Nokogiri时,我遇到了阻止我的应用程序运行的相同问题。我怀疑这个问题是本地的,并且是将所有内容都移到了Rails 5,但我不确定。这是错误消息:

An error occurred while installing nokogiri (1.8.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.1'` succeeds before bundling.

In Gemfile:
  rails_admin was resolved to 1.2.0, which depends on
    rails was resolved to 5.1.3, which depends on
      actioncable was resolved to 5.1.3, which depends on
        actionpack was resolved to 5.1.3, which depends on
          actionview was resolved to 5.1.3, which depends on
            rails-dom-testing was resolved to 2.0.3, which depends on
              nokogiri

(这来自运行Bundle Install)我尝试运行Bundle Update并使用Gi​​thub推荐的各种Homebrew命令,但我没有取得任何成功。

Gen S看到-v'1.8.1'

1 error generated.
make[2]: *** [xmlIO.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
ruby-on-rails nokogiri
8个回答
5
投票

Nokogiri无法正常构建,因为你没有像libxml2这样的开发库。查看日志文件以查看发生的情况或尝试使用brew install libxml2直接安装libxml2

请参阅由http://www.nokogiri.org/tutorials/installing_nokogiri.html的Nokogiry提供的引导指南


12
投票

(对于UBUNTU)首先尝试这样做

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzmadev

然后尝试安装。


5
投票

我只是发布了我找到的解决方案(我在MacOS上遇到了同样的问题)。有了这个,gem将使用系统库安装,这将解决您遇到的问题。

  1. 如果使用gem:
gem install nokogiri -- --use-system-libraries
 [--with-xml2-config=/path/to/xml2-config]
 [--with-xslt-config=/path/to/xslt-config]
  1. 如果使用捆绑:
bundle config build.nokogiri --use-system-libraries
bundle install

2
投票

以下是可能有助于您解决此问题的步骤:

  1. gem update —system
  2. 安装Xcode命令行工具:xcode-select —install
  3. 最后现在安装Nokogiri:gem install nokogiri

1
投票

构建需要libxml2和zlib,您需要同时安装它们。

Fedora:

sudo dnf install libxml2-devel zlib-devel

Ubuntu:

sudo apt install libxml2-dev zlib1g-dev 

1
投票

在高山脉(和莫哈韦沙漠),这对我有用

gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2/

bundle update

bundle install

0
投票

升级Xcode后出现同样的问题

我不得不跑:sudo xcode-select --switch /Library/Developer/CommandLineTools/ then: sudo bundle install --system

之后一切都很好。


0
投票

如果使用MAC OS你可以尝试

brew unlink xz
gem install nokogiri
brew link xz

我使用MAC OS,并使用brew install ruby来避免搞乱系统的红宝石环境,以下bundle install非常顺利。

© www.soinside.com 2019 - 2024. All rights reserved.