安装 nokogiri (1.6.7.2) 时出现捆绑安装错误。 Gem 次安装但不适用于 rails 应用
Bundle install error installing nokogiri (1.6.7.2). Gem installs but not for rails app
我正在开发一个使用 ruby 2.1.5 的 rails 项目。我下载了 rvm,安装了 ruby 2.1.5,目前正在使用它。我在 Ubuntu 18.04。我在 运行 bundle install
时收到以下错误
此外,当我按照指示尝试 gem install nokogiri -v '1.6.7.2'
时,它安装得很好。在这种情况下,我找不到另一个问题。
我查看了这个问题 并尝试了所有解决方案。这可能是我遇到的另一个问题。可能和rvm有关,但我不确定。
$ bundle install
Fetching gem metadata from https://rubygems.org/........
Using rake 11.1.2
Using CFPropertyList 2.3.3
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.4
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Fetching nokogiri 1.6.7.2
Installing nokogiri 1.6.7.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.7.2/ext/nokogiri
/usr/share/rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20190123-15188-1qpzj0b.rb extconf.rb
--use-system-libraries
checking if the C compiler accepts ... *** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/share/rvm/rubies/ruby-2.1.5/bin/ruby
--help
--clean
/usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:571:in `block in try_compile'
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:522:in `with_werror'
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:621:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:336:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.6.7.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.7.2
for inspection.
Results logged to
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.6.7.2/gem_make.out
An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7.2' --source 'https://rubygems.org/'` succeeds
before bundling.
In Gemfile:
rails was resolved to 4.2.4, which depends on
actionmailer was resolved to 4.2.4, which depends on
actionpack was resolved to 4.2.4, which depends on
actionview was resolved to 4.2.4, which depends on
rails-dom-testing was resolved to 1.0.7, which depends on
nokogiri
但是如你所见,当我运行gem install nokogiri -v '1.6.7.2'
看起来没有问题
$ gem install nokogiri -v 1.6.7.2
Building native extensions. This could take a while...
Successfully installed nokogiri-1.6.7.2
Parsing documentation for nokogiri-1.6.7.2
Done installing documentation for nokogiri after 2 seconds
1 gem installed
根据此处的参考 Installing Nokogiri
gem update --system
xcode-select --install # Then agree to the terms, even if you have done this before!
gem install nokogiri
# if that's still not working uninstall the old nokogiri
gem uninstall nokogiri
javier 已经提到 mac os 和 ubuntu 上面的选项(在其他答案中,如果问题仍然存在,我的建议是 gem 卸载 nokogiri首先然后执行 gem install nokogiri -v '1.6.7.2'
这些是 ubuntu docs
的说明
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
对于 rvm
sudo apt-get install libgmp-dev
使用系统库构建
sudo apt-get install libxml2-dev libxslt1-dev
安装
gem install nokogiri --use-system-libraries
我修复了它,但这可能是一个不令人满意的答案。我仔细阅读了所有建议,安装了各种依赖项,更改了各种设置。似乎没有任何效果。 然后我把工程文件夹删了再从Github里拉出来,重装rvm,又运行bundle install
一切正常
那么我缺少的一件事是什么?我不能确定。但我可以说,如果没有其他工作,请创建一个新文件夹并再次下载项目,然后 运行 bundle install
..当然首先安装所有依赖项/工具后,在这里找到 -> https://nokogiri.org/tutorials/installing_nokogiri.html
我正在开发一个使用 ruby 2.1.5 的 rails 项目。我下载了 rvm,安装了 ruby 2.1.5,目前正在使用它。我在 Ubuntu 18.04。我在 运行 bundle install
此外,当我按照指示尝试 gem install nokogiri -v '1.6.7.2'
时,它安装得很好。在这种情况下,我找不到另一个问题。
我查看了这个问题
$ bundle install
Fetching gem metadata from https://rubygems.org/........
Using rake 11.1.2
Using CFPropertyList 2.3.3
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.4
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Fetching nokogiri 1.6.7.2
Installing nokogiri 1.6.7.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.7.2/ext/nokogiri
/usr/share/rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20190123-15188-1qpzj0b.rb extconf.rb
--use-system-libraries
checking if the C compiler accepts ... *** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/share/rvm/rubies/ruby-2.1.5/bin/ruby
--help
--clean
/usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:571:in `block in try_compile'
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:522:in `with_werror'
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /usr/share/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/mkmf.rb:621:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:336:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.6.7.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.7.2
for inspection.
Results logged to
/media/mcgoy/CD25-ED8E/Upwork/EVSlideShow/Rails/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.6.7.2/gem_make.out
An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7.2' --source 'https://rubygems.org/'` succeeds
before bundling.
In Gemfile:
rails was resolved to 4.2.4, which depends on
actionmailer was resolved to 4.2.4, which depends on
actionpack was resolved to 4.2.4, which depends on
actionview was resolved to 4.2.4, which depends on
rails-dom-testing was resolved to 1.0.7, which depends on
nokogiri
但是如你所见,当我运行gem install nokogiri -v '1.6.7.2'
看起来没有问题
$ gem install nokogiri -v 1.6.7.2
Building native extensions. This could take a while...
Successfully installed nokogiri-1.6.7.2
Parsing documentation for nokogiri-1.6.7.2
Done installing documentation for nokogiri after 2 seconds
1 gem installed
根据此处的参考 Installing Nokogiri
gem update --system
xcode-select --install # Then agree to the terms, even if you have done this before!
gem install nokogiri
# if that's still not working uninstall the old nokogiri
gem uninstall nokogiri
javier 已经提到 mac os 和 ubuntu 上面的选项(在其他答案中,如果问题仍然存在,我的建议是 gem 卸载 nokogiri首先然后执行 gem install nokogiri -v '1.6.7.2'
这些是 ubuntu docs
的说明sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
对于 rvm
sudo apt-get install libgmp-dev
使用系统库构建
sudo apt-get install libxml2-dev libxslt1-dev
安装
gem install nokogiri --use-system-libraries
我修复了它,但这可能是一个不令人满意的答案。我仔细阅读了所有建议,安装了各种依赖项,更改了各种设置。似乎没有任何效果。 然后我把工程文件夹删了再从Github里拉出来,重装rvm,又运行bundle install
一切正常
那么我缺少的一件事是什么?我不能确定。但我可以说,如果没有其他工作,请创建一个新文件夹并再次下载项目,然后 运行 bundle install
..当然首先安装所有依赖项/工具后,在这里找到 -> https://nokogiri.org/tutorials/installing_nokogiri.html