本文介绍了无法在 ruby​​ 2.3.1 上安装 rails gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 ruby​​ 2.3.1 上安装导轨.

I am trying to install rails on ruby 2.3.1.

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

安装了 Ruby.

$ rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

RVM 存在.

$ gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.1/gems/nokogiri-1.7.0.1/ext/nokogiri
/usr/local/rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20170227-6774-1l4uc6c.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20170227-6774-1l4uc6c.rb extconf.rb 2>&1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.1/gems/nokogiri-1.7.0.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.1/extensions/x86_64-linux/2.3.0/nokogiri-1.7.0.1/gem_make.out

当我调用 gem list 时,我没有看到 nokogari 和 rails.$ 宝石列表

When I call gem list, I don't see nokogari nor rails. $ gem list

 *** LOCAL GEMS ***
...
minitest (5.8.3)
net-telnet (0.1.1)
pg (0.19.0)
power_assert (0.2.6)
psych (2.0.17)
rack (2.0.1)
rack-test (0.6.3)
raindrops (0.17.0)
rake (10.4.2)
rdoc (4.2.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.1.5)
...

我不知道出了什么问题.

I donot know what is wrong.

推荐答案

按照这里的说明(忽略日语,直接使用代码!http://qiita.com/riocampos/items/43b55ba06e6c3ec01b82

follow instruction here (ignore the japanes, just use the code!http://qiita.com/riocampos/items/43b55ba06e6c3ec01b82

$ brew update

$ brew install libxml2

$ brew link --force libxml2

$ gem install nokogiri -- --use-system-libraries

如果出现问题,请使用 sudo:

in case of problems use sudo:

sudo gem install nokogiri -- --use-system-libraries libxml2

猜测系统 10.2.3 使用了不兼容的 libxml2,因此强制链接到与 homebrew 一起安装的过时"libxml2 可以完成这项工作.

guess System 10.2.3 uses incompatible libxml2, so forced linking to the «outdated» libxml2 installed with homebrew does the job.

这篇关于无法在 ruby​​ 2.3.1 上安装 rails gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 17:57
查看更多