3

Catching this error under Ubuntu 12.04:

Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.

/home/allaud/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
creating Makefile

make
compiling generator.c
linking shared-object json/ext/generator.so
gcc: error: generator.o: No such file or directory
make: *** [generator.so] Ошибка 1

Gem files will remain installed in /home/allaud/.rvm/gems/ruby-1.9.3-p392/gems/json-1.7.7 for inspection.
Results logged to /home/allaud/.rvm/gems/ruby-1.9.3-p392/gems/json-1.7.7/ext/json/ext/generator/gem_make.out

I am using fresh rvm and ruby 1.9.3 and have same trouble only with json gem.

The error occurs when I try to execute:

gem install json

If I add sudo everything is ok, but I cannot (and shouldn't) use sudo with rvm commands.

3 Answers3

3
sudo apt-get install ruby1.9.1-dev

may fix it .Cheers !

aelor
  • 10,892
  • 3
  • 32
  • 48
2

Try running below commands(works for ubuntu 14.04):

$ sudo apt-get install libgmp3-dev

and then install json

$ gem install json

Reference: https://www.digitalocean.com/community/questions/how-do-i-fix-this-error-when-deploying-rails-with-capistrano-using-nginx-and-puma

Abhinay
  • 1,796
  • 4
  • 28
  • 52
0

For me this worked (a solution from @mjgpy3)

sudo apt-get install ruby-json
techvineet
  • 5,041
  • 2
  • 30
  • 28