Can't install json gem with ruby ​​2.2.3 on Ubuntu

I am looking through a Rails tutorial and I cannot complete the “package installation” due to a json gem problem. When I try 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.

 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 Gemfile should require 1.8.3 by default. The search revealed many similar questions, but no answers that made me pass this problem. I tried working with sudo and it seems to work, but coming back to me, the problem still exists.

+46
json ruby ruby-on-rails
Aug 21 '15 at 0:41
source share
3 answers

cannot find -lgmp means that it cannot find the gmp library. Try to run:

 sudo apt-get install libgmp3-dev 

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

+147
Aug 24 '15 at 21:04
source share
— -

Json 1.8.3 seems to have some problems with Ruby 2.2.3 (although I expect some future Ruby patches will probably fix the problem). For me, a downgrade of Ruby to 2.2.2 worked.

(However, sudo apt-get install libgmp3-dev , like @alf , but if you are "unable to do this, lowering the ruby ​​may be an acceptable alternative.)

+3
Sep 01 '15 at 2:06 on
source share

Try running rvm implode and then follow this guide http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/

I suspect that the RVM did not include the correct headers for you.

0
Aug 21 '15 at 0:54
source share



All Articles