Gem文件不会更新或与捆绑软件一起安装 [英] Gem File won't update or install with bundler

查看:216
本文介绍了Gem文件不会更新或与捆绑软件一起安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Michael Hartl的RoR教程。我在第3章。不幸的是,复制和粘贴gem文件对我不起作用,但我找出了哪个gem是问题。这是水豚宝石。我已经评论过了,继续了教程,但我已经到了需要使用gem的地步。



这是一个示例$ bundle update给我一个错误:

  $ bundle update 
从https://rubygems.org / ....获取gem元数据.....

(删除了一堆文本)

使用系统库构建nokogiri。

Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展。

/Users/dbz/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb --use-system-libraries
使用系统库构建nokogiri。
libxml2版本2.6.21或更高版本是必需的!
*** extconf.rb失败***
由于某些原因无法创建Makefile,可能缺少必要的
库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。

(删除了一堆文本)


Gem文件将保留安装在/Users/dbz/.rvm/gems/ruby-2.0.0-p481 /gems/nokogiri-1.6.3.1进行检查。
记录到/Users/dbz/.rvm/gems/ruby-2.0.0-p481/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out
的结果安装nokogiri时发生错误(1.6.3.1),并且Bundler不能
继续。
在捆绑之前确保`gem install nokogiri -v'1.6.3.1'`成功。

我尝试去nokogiri网站并解决问题,但是当我尝试更新缺失的库时(错误的早期部分),我的机器说我已经有了它们。



这是我的Gemfile:

  source'https:// rubygems.org'
ruby​​'2.0.0'
#ruby-gemset = railstutorial_rails_4_0

gem'rails','4.0.8'

group:development,:test do
gem'sqlite3','1.3.8'
gem'rspec-rails','2.13.1'
end

group:test do
gem'selenium-webdriver','2.35.1'
#gem'capybara','2.1.0'#这行代码打破了所有
结束

gem'sass-rails','4.0.1'
gem'uglifier','2.1.1'
gem'coffee-rails','4.0.1'
gem 'jquery-rails','3.0.4'
gem'turbolinks','1.1.1'
gem'jbuilder','1.0.2'

group:doc do
gem'sdoc','0.3.20',要求:false
end

group:production do
gem'pg','0.15.1'
gem'rails_12factor','0.0.2'
end

编辑:从 http://nokogiri.org/tutorials/installing_nokogiri.html 安装页面



我遵循了所有步骤,并在最后一步,我需要运行命令

  gem install nokogiri  -   - -with-xml2-include = / usr / local / Cellar / libxml2 / 2.7.8 / include / libxml2 
--with-xml2-lib = / usr / local / Cellar / libxml2 / 2.7.8 / lib
--with-xslt-dir = / usr / local / Cellar / libxslt / 1.1.26
--with-iconv-include = / usr / local / Cellar / libiconv / 1.13.1 / include
--with-iconv-lib = / usr / local / Cellar / libiconv / 1.13.1 / lib

我的控制台的输出是:

  Daniels-MacBook-Air:libiconv-1.13.1 dbz $ pwd 
/Users/dbz/libiconv-1.13.1
Daniels-MacBook-Air:libiconv-1.13.1 dbz $ gem install nokogiri - --with-xml2- include = / usr / local / Cellar / libxml2 / 2.7.8 / include / libxml2
--with-xml2-lib = / usr / local / Cellar / libxml2 / 2.7.8 / lib
--with-xslt-dir = / usr / local / Cellar / libxslt / 1.1.26
--with-iconv-include = / usr / local / Cellar / libiconv / 1.13.1 / include
--with-iconv-lib = / usr / local / Cellar / libiconv / 1.13.1 / lib
使用以下命令构建本地扩展:'--with-xml2- include = / usr / local / Cellar / libxml2 / 2.7.8 / include / libxml2'
这可能需要一段时间...
Building nokogiri使用打包库。
错误:安装nokogiri时出错:
错误:无法构建gem原生扩展。

/Users/dbz/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb --with-xml2- include = / usr / local / Cellar / libxml2 / 2.7 .8 / include / libxml2
使用打包的库构建nokogiri。
-----
libiconv丢失。请访问http://nokogiri.org/tutorials/installing_nokogiri.html获取安装依赖关系的帮助。
-----
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少必要的
库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。

提供的配置选项:
--with-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 = / Users / dbz / .rvm / rubies / ruby​​-2.0.0-p481 / bin / ruby​​
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib- dir
--with-zlib-include
--without-zlib-include = $ {zlib-dir} / include
--with-zlib-lib
--without -zlib-lib = $ {zlib-dir} / lib
- 启用交叉编译
- 禁用交叉编译


Gem文件将保持安装在/Users/dbz/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/nokogiri-1.6.3.1进行检查。
结果记录到/Users/dbz/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out
Daniels-MacBook- Air:libiconv-1.13.1 dbz $ --with-xml2-lib = / usr / local / Cellar / libxml2 / 2.7.8 / lib
-bash:--with-xml2-lib = / usr / local /Cellar/libxml2/2.7.8/lib:没有这样的文件或目录
Daniels-MacBook -Air:libiconv-1.13.1 dbz $ --with-xslt-dir = / usr / local / Cellar / libxslt / 1.1.26
-bash:--with-xslt-dir = / usr / local / Cellar / libxslt / 1.1.26:没有这样的文件或目录
Daniels-MacBook-Air:libiconv-1.13。 1 dbz $ --with-iconv-include = / usr / local / Cellar / libiconv / 1.13.1 / include
-bash:--with-iconv-include = / usr / local / Cellar / libiconv / 1.13 .1 / include:没有这样的文件或目录
Daniels-MacBook -Air:libiconv-1.13.1 dbz $ --with-iconv-lib = / usr / local / Cellar / libiconv / 1.13.1 / lib
-bash:--with-iconv-lib = / usr / local / Cellar / libiconv / 1.13.1 / lib:没有这样的文件或d irectory


解决方案

我找到了一个解决方案:

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

发自: Nokogiri'无法构建gem原生扩展'当我运行bundle install时



消息来源: https://github.com/sparklemotion/nokogiri/issues/1099#issuecomment-43023208


I'm working on Michael Hartl's RoR tutorials. I'm on chapter 3. Unfortunately, copy and pasting the gem files won't work for me, but I figured out which gem is the problem. It's the capybara gem. I've commented it out and continued the tutorial, but I'm at the point where I need to use the gem.

Here is an example $bundle update giving me an error:

$ bundle update
Fetching gem metadata from https://rubygems.org/.........

(Removed a bunch of text)

Building nokogiri using system libraries.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/dbz/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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.

(Removed a bunch of text)


Gem files will remain installed in /Users/dbz/.rvm/gems/ruby-2.0.0-p481/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/dbz/.rvm/gems/ruby-2.0.0-p481/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.6.3.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling.

I tried going to the nokogiri website and fixing the problem, but when I try to update the missing libraries (an earlier part of the error), my machine says I already have them.

Here is my Gemfile:

source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.8'

group :development, :test do
  gem 'sqlite3', '1.3.8'
  gem 'rspec-rails', '2.13.1'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  #gem 'capybara', '2.1.0'   # This line breaks everything
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

EDIT: From the http://nokogiri.org/tutorials/installing_nokogiri.html install page

I followed all of the steps and at the final step where I need to run the command

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 
                    --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib 
                    --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 
                    --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include 
                    --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

The output from my console is:

Daniels-MacBook-Air:libiconv-1.13.1 dbz$ pwd
/Users/dbz/libiconv-1.13.1
Daniels-MacBook-Air:libiconv-1.13.1 dbz$ gem install nokogiri -- --with-xml2-    include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 
                    --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib 
                    --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 
                    --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include 
                    --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
Building native extensions with: '--with-xml2-    include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2'
This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/dbz/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb --with-xml2-    include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2
Building nokogiri using packaged libraries.
-----
libiconv is missing.  please visit     http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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
    --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=/Users/dbz/.rvm/rubies/ruby-2.0.0-p481/bin/ruby
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build


Gem files will remain installed in /Users/dbz/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/nokogiri-1.6.3.1 for inspection.
Results logged to /Users/dbz/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out
Daniels-MacBook-Air:libiconv-1.13.1 dbz$                         --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib 
-bash: --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib: No such file or directory
Daniels-MacBook-Air:libiconv-1.13.1 dbz$                         --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 
-bash: --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26: No such file or directory
Daniels-MacBook-Air:libiconv-1.13.1 dbz$                         --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include 
-bash: --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include: No such file or directory
Daniels-MacBook-Air:libiconv-1.13.1 dbz$                         --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
-bash: --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib: No such file or directory

解决方案

I found a solution that worked:

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

From: Nokogiri 'Failed to build gem native extension' when I run bundle install

Source's source: https://github.com/sparklemotion/nokogiri/issues/1099#issuecomment-43023208

这篇关于Gem文件不会更新或与捆绑软件一起安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆