我正在尝试在我的电脑上安装Rails 4.2.0,但是我在安装Nokogiri时遇到了问题。我按照"bundle install stopped at Nokogiri"中第一个答案的步骤进行操作,但是当我运行brew install nokogiri
时,出现以下错误:
Activating libxslt 1.1.28 (from /Users/dseibert/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2/ports/x86_64-apple-darwin14.0.0/libxslt/1.1.28)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
-----
*** 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/dseibert/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--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
--with-xml2lib
--without-xml2lib
--with-libxml2lib
--without-libxml2lib
extconf failed, exit code 1
Gem files will remain installed in /Users/dseibert/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/dseibert/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/nokogiri-1.6.6.2/gem_make.out
我找不到mkmf文件来定位我的libxml2文件的详细信息,而且在我的Ruby源文件夹中也看不到libxml2文件或Nokogiri文件夹。当我运行
brew install libxml2
时,我得到了警告:libxml2-2.9.2已经安装
的提示。
根据评论,我收到了回复:
nokogiri-1.6.6.2安装成功
。但是当我运行sudo gem install rails
时,我又收到了上述错误。
sudo gem install rails
。sudo
会将您的权限提升到 root 用户,而 root 用户对于 Ruby 在您的计算机上的位置有完全不同的想法。当使用 RVM 或 rbenv 时,永远不要使用sudo
安装 gem。相反,只需使用gem install some_gem
即可。这样应该就可以了。 - the Tin Man