当运行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并使用Github推荐的各种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.
Nokogiri无法正常构建,因为你没有像libxml2这样的开发库。查看日志文件以查看发生的情况或尝试使用brew install libxml2
直接安装libxml2
请参阅由http://www.nokogiri.org/tutorials/installing_nokogiri.html的Nokogiry提供的引导指南
(对于UBUNTU)首先尝试这样做
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzmadev
然后尝试安装。
我只是发布了我找到的解决方案(我在MacOS上遇到了同样的问题)。有了这个,gem将使用系统库安装,这将解决您遇到的问题。
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
bundle config build.nokogiri --use-system-libraries
bundle install
以下是可能有助于您解决此问题的步骤:
gem update —system
xcode-select —install
gem install nokogiri
构建需要libxml2和zlib,您需要同时安装它们。
sudo dnf install libxml2-devel zlib-devel
sudo apt install libxml2-dev zlib1g-dev
在高山脉(和莫哈韦沙漠),这对我有用
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
升级Xcode后出现同样的问题
我不得不跑:sudo xcode-select --switch /Library/Developer/CommandLineTools/
then: sudo bundle install --system
之后一切都很好。
如果使用MAC OS你可以尝试
brew unlink xz
gem install nokogiri
brew link xz
我使用MAC OS,并使用brew install ruby
来避免搞乱系统的红宝石环境,以下bundle install
非常顺利。