我尝试捆绑安装时遇到此错误
Bundler::GemspecError: Could not read gem at /home/theareba/.rvm/gems/ruby-2.0.0-p353/cache/nokogiri-1.6.1.gem. It may be corrupted.
An error occurred while installing nokogiri (1.6.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
我已经尝试在缓存中删除nokogiri并再次捆绑安装是徒劳的。 这是我的宝石文件
source 'https://rubygems.org'
gem 'rails', '4.0.0'
ruby "2.0.0"
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-1-stable'
gem 'spree', github: 'spree/spree', branch: '2-1-stable'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder'
group :development, :test do
gem 'turn', :require => false
gem 'sqlite3'
gem 'taps', :require => false
gem 'rspec-rails'
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor'
end
更新 运行gem install nokogiri -v'1.6.0'
时发生错误Fetching: mini_portile-0.5.2.gem (100%)
Fetching: nokogiri-1.6.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.6.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
注意:我已经安装了nokogiri安装中的要求libxslt1-dev
和libxml2-dev
。
我也试过了gem install nokogiri -v '1.6.1'
但它仍然失败了。我已经在另一个应用程序中安装了nokogiri -v 1.5.0,所以我在这个应用程序中尝试了它并且得到了狂欢需要nokogiri版本1.6.0或更高版本的错误。我错过了什么?
答案 0 :(得分:4)
所以这就解决了我的问题。我创建了一个新的宝石集,即
rvm gemset create nokogiri
rvm use ruby-2.0.0-p353@nokogiri
注意:我正在使用rvm和ruby 2.0.0。然后我确保通过运行
安装了必要的libsudo apt-get install libxml2-dev libxslt-dev
库已经安装好了。然后我安装了nokogiri
gem install nokogiri -v '1.6.1'
安装成功。最后跑bundle install
来获取我所有的宝石。希望这有助于任何人遇到同样的问题。
答案 1 :(得分:0)
检查RVM gemset。我通过恢复gemset来修复它。如果您尝试升级到4.0.2?我使用Nokogiri 1.6.1和Ruby 2.0.0以及Rails 4.0.2
答案 2 :(得分:0)
试试这个
sudo apt-get install ruby-dev
sudo apt-get install libxml2 libxml2-dev libxslt1-dev
并重新安装nokogiri
sudo gem install nokogiri