Ruby on rails 为什么'gem install'可以工作,而'bundle install'不能工作`
在我的项目中,当我运行Ruby on rails 为什么'gem install'可以工作,而'bundle install'不能工作`,ruby-on-rails,macos,rvm,bundler,nokogiri,Ruby On Rails,Macos,Rvm,Bundler,Nokogiri,在我的项目中,当我运行bundle安装时出现以下错误: 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. 所以我试过了 gem install nokogiri -v '1.6.1' 这确实奏效了。当然这会让我很高兴,但我现在想知
bundle安装时
出现以下错误:
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.
所以我试过了
gem install nokogiri -v '1.6.1'
这确实奏效了。当然这会让我很高兴,但我现在想知道,到底是什么让我安装了gem,现在bundle安装也成功了
我正在运行MacOSX10.9.2
这是我第一次运行捆绑安装时的日志
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/me/.rvm/rubies/ruby-1.9.3-p545/bin/ruby extconf.rb --with-xml2-dir=/usr --with-xslt-dir=/opt/local --with-iconv-dir=/opt/local
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Users/me/.rvm/gems/ruby-1.9.3-p545/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Users/me/.rvm/gems/ruby-1.9.3-p545/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxslt/1.1.26)...
checking for libxml/parser.h... no
-----
libxml2 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/me/.rvm/rubies/ruby-1.9.3-p545/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-libiconv-config
--without-libiconv-config
extconf failed, exit code 1
Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.3-p545/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.9.3-p545/extensions/x86_64-darwin-13/1.9.1/nokogiri-1.6.1/gem_make.out
试试这个:
brew install libxml2 libxslt libiconv
无法仅通过bundle install
安装它的原因是bundler
只处理gem依赖项,而不是本地依赖项。gem要求您的系统具有您没有的libxml2
。所以你需要安装它们。提示我答案的是日志中的以下错误消息:
ERROR: Failed to build gem native extension.
缺少依赖项时出错。你试过安装它们吗?谢谢你的提示。我的问题是为什么我可以通过gem install
安装gem,而不是通过bundle install
安装gem。但是gem install nokogiri-v'1.6.1'
安装所需的依赖项吗?不太确定。。原因可能是--include dependencies
是gem install
的默认选项,您的假设可能是正确的。由于它现在已成功安装,因此很难找出实际问题所在。