我正在阅读Rails教程,由于json gem的问题,我无法完成'bundle install'。当我尝试直接安装它时:
me@tru2:~/rails/hello_app$ gem install json -v '1.8.3'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/home/me/.rvm/rubies/ruby-2.2.3-dev/bin/ruby -r ./siteconf20150820-12793-qdkev7.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.so
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
make: *** [generator.so] Error 1
make failed, exit code 2
Gem files will remain installed in /home/me/.rvm/gems/ruby-2.2.3-dev/gems/json-1.8.3 for inspection.
Results logged to /home/me/.rvm/gems/ruby-2.2.3-dev/extensions/x86_64-linux/2.2.0/json-1.8.3/gem_make.out
如上所述,ruby版本是2.2.3。
me@tru2:~/rails/hello_app$ ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
运行'gem list'表示当前安装了json 1.8.1,但默认Gemfile中的某些内容必须要求1.8.3。搜索显示了许多类似的问题,但没有答案让我超越了这个问题。我试过用sudo运行它似乎工作但回到我身边的问题仍然存在。
答案 0 :(得分:146)
cannot find -lgmp
表示无法找到gmp库。尝试运行:
sudo apt-get install libgmp3-dev
答案 1 :(得分:4)
(也就是说sudo apt-get install libgmp3-dev
,@alf suggested也是如此 - 但如果您无法做到这一点,降级ruby可能是一种可行的选择。)< / p>
答案 2 :(得分:0)
尝试运行rvm implode
,然后按照本指南http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/
我怀疑RVM没有为您提供正确的标题。