简体   繁体   English

无法在Ubuntu上安装带有ruby 2.2.3的json gem

[英]Can not install json gem with ruby 2.2.3 on Ubuntu

I am going through a Rails tutorial and I'm not able to complete 'bundle install' due to a problem with the json gem. 我正在阅读Rails教程,由于json gem的问题,我无法完成'bundle install'。 When I attempt to install it directly: 当我尝试直接安装它时:

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

As mentioned the ruby version is 2.2.3. 如上所述,ruby版本是2.2.3。

me@tru2:~/rails/hello_app$ ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

Running 'gem list' shows that json 1.8.1 is currently installed but something in the default Gemfile must require 1.8.3. 运行'gem list'表示当前安装了json 1.8.1,但默认Gemfile中的某些内容必须要求1.8.3。 A search showed many similar questions but no answers that got me past this issue. 搜索显示了许多类似的问题,但没有答案让我超越了这个问题。 I have tried running with sudo and it appears to work but going back to me the issue is still there. 我试过用sudo运行它似乎工作但回到我身边的问题仍然存在。

cannot find -lgmp means that it can't find the gmp library. cannot find -lgmp意味着找不到gmp库。 Try running: 试试跑步:

sudo apt-get install libgmp3-dev

https://github.com/flori/json/issues/253 https://github.com/flori/json/issues/253

Json 1.8.3 seems to have some issues with Ruby 2.2.3 (though I expect some future patches of Ruby will probably fix the problem). Json 1.8.3似乎在Ruby 2.2.3中存在一些问题(尽管我预计未来的一些Ruby补丁可能会解决这个问题)。 Downgrading Ruby to 2.2.2 worked for me. 将Ruby降级到2.2.2对我有用。

(That said, so did sudo apt-get install libgmp3-dev , as @alf suggested - but if you're not able to do that, downgrading ruby might be a feasible alternative.) (也就是说, sudo apt-get install libgmp3-dev也是如此 ,正如@alf 建议的那样 - 但是如果你无法做到这一点,那么降级ruby可能是一个可行的选择。)

Try running rvm implode and then following this guide http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/ 尝试运行rvm implode然后按照本指南http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/

I suspect RVM did not include the correct headers for you. 我怀疑RVM没有为您包含正确的标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM