Rails - Failed to build native extensions - ruby-on-rails

I'm currently trying to embark on my first rails project and when I try to run the command rails new file_name I eventually get the error ERROR: Failed to build gem native extension.
I am currently using rvm to run ruby 2.2 on my mac osx 10.8.5. Everytime I run rails it seems to fail at the json gem.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
I am lost as to what is going on. If I try to run install json I also get a failed to build native extension error. Could it be my versions of xcode command line tools because when I try to run xcode-select --install it says command doesn't exist? I don't know. Any help would be appreciated.
edit as per Leonardo's request:
Installing json 1.8.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/davidgarczynski/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150817-32366-1n36tmw.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
make: I.: No such file or directory
make: [generator.o] Error 1 (ignored)
linking shared-object json/ext/generator.bundle
make: dynamic: No such file or directory
make: [generator.bundle] Error 1 (ignored)
make "DESTDIR=" install
compiling generator.c
make: I.: No such file or directory
make: [generator.o] Error 1 (ignored)
linking shared-object json/ext/generator.bundle
make: dynamic: No such file or directory
make: [generator.bundle] Error 1 (ignored)
/usr/bin/install -m 0755 generator.bundle ./.gem.20150817-32366-b8ng6y/json/ext
install: generator.bundle: No such file or directory
make: *** [install-so] Error 71
make install failed, exit code 2
Gem files will remain installed in /Users/davidgarczynski/.rvm/gems/ruby-2.2.1/gems/json-1.8.3 for inspection.
Results logged to /Users/davidgarczynski/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/json-1.8.3/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure thatgem install json -v '1.8.3'succeeds before bundling.

Related

Installing json -v '1.8.6' gem, throws gcc error

some one in my team just updated some gem in the gemfile because of which gem json is resolved to version '1.8.6'. Which is not being installed. The error it throws is following:
anas:~$ sudo gem install json -v '1.8.6'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/json-
1.8.6/ext/json/ext/generator
/usr/bin/ruby2.3 -r ./siteconf20171017-7274-1ea5ank.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/2.3.0/gems/json-
1.8.6/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /var/lib/gems/2.3.0/gems/json-
1.8.86/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
gcc: error: unrecognized command line option ‘-Wdate-time’
gcc: error: unrecognized command line option ‘-fstack-protector-
strong’
Makefile:239: recipe for target 'generator.o' failed
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.3.0/gems/json-1.8.6
for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-
linux/2.3.0/json-1.8.6/gem_make.out
My ruby is 2.3.1p112 and gcc version is 4.7.4. I have tried to find out which gcc version json -v 1.8.6 use but I did not find anything.
Thanks in advance
As pr my undarstanding the solution is to install libgmp3-dev.
sudo apt-get install libgmp3-dev

Error installing therubyracer on osx 10.12.4

I have gone through a lot of answers on a similar questions but I have not been successful. I am trying to install therubyracer 0.12.3 on my MAC OSX 10.12.4 and I am receiving the following error. Please help. Been stuck with this for two days now.
sudo gem install therubyracer -v '0.12.3'
Building native extensions.
This could take a while... ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
current directory: /Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3/ext/v8
/Users/aj035785/.rvm/rubies/ruby-2.3.1/bin/ruby -r
./siteconf20170420-2619-13h8man.rb extconf.rb checking for main() in
-lpthread... yes checking for main() in -lobjc... yes creating Makefile
current directory:
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3/ext/v8
make "DESTDIR=" clean
current directory:
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3/ext/v8
make "DESTDIR=" compiling accessor.cc make:
/usr/local/opt/apple-gcc42/bin/g++-4.2: No such file or directory
make: *** [accessor.o] Error 1
make failed, exit code 2
Gem files will remain installed in
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3
for inspection. Results logged to
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0/therubyracer-0.12.3/gem_make.out
Blockquote
I feel this might be the root cause -
make: /usr/local/opt/apple-gcc42/bin/g++-4.2: No such file or directory

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. windows 8

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe -r ./siteconf20161107-1492-fykpuh.rb extconf.rb
--use-system-libraries
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
generating generator-i386-mingw32.def
compiling generator.c
make: execvp: gcc: Bad file number
make: *** [generator.o] Error 127
make failed, exit code 2
Gem files will remain installed in C:/Ruby/lib/ruby/gems/2.2.0/gems/json-1.8.3
for inspection.
Results logged to
C:/Ruby/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/json-1.8.3/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

json doesn't install despite all i have done

I have been trying to solve this for days but i still cannot figure it out. JSON is still not installing. i will appreciate your help
C:\Users\Max Billionaire>gem install json --no-rdoc --no-ri
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: C:/ruby/lib/ruby/gems/2.1.0/gems/json 1.8.3/ext/json/ext/generator
C:/ruby/bin/ruby.exe -r ./siteconf20160417-268-iqr9ay.rb extconf.rb
creating Makefile
current directory: C:/ruby/lib/ruby/gems/2.1.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean
current directory: C:/ruby/lib/ruby/gems/2.1.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
generating generator-i386-mingw32.def
compiling generator.c
cc1.exe: internal compiler error: Illegal instruction
Please submit a full bug report, with preprocessed source if appropriate.
See <mingw-w64-public#lists.sourceforge.net> for instructions.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in C:/ruby/lib/ruby/gems/2.1.0/gems/json-1.8.3 for inspection.
Results logged to C:/ruby/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/json-
1.8.3/gem_make.out`

Error installing gem

I typed 'gem install middleman' in my terminal and got the following error message:
Building native extensions. This could take a while...
ERROR: Error installing middleman:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
creating Makefile
make
compiling hitimes.c
make: gcc-4.2: No such file or directory
make: *** [hitimes.o] Error 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p429/gems/hitimes-1.2.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p429/gems/hitimes-1.2.2/ext/hitimes/c/gem_make.out
Looks like you're missing gcc-4.2
Do you have any GCC installed (if you're on a Mac, you need to install Xcode)?
which gcc
If you already have a version of gcc, you can simply symlink to it
ln -s /usr/bin/gcc /usr/bin/gcc-4.2

Resources