I'm new to Terminal so please bear with me. Completed installing the following successfully (in this particular order):
xCode 4.5
RVM 1.16
GCC 4.2.1
Ruby 1.9.3
When trying to install Rails ("gem install rails") the installation starts but is then interrupted with an error: "Failed to build gem native extension". No idea what this refers to. Ideas? Something else I need to install beforehand?
On my first attempt to install Rails I accidentally ran it with sudo. Will this affect anything?
Edit: And the output -
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/staffanestberg/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /Users/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection.
Results logged to /Users/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
Edit: Solved using iouri's suggestion. Add export CC=gcc in .bash-profile then create a symlink for the correct compiler,
sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Make sure you have command line tools for Xcode installed first, Xcode > Preferences > Downloads > Components. Then add this line to your .bash_profile file in your home folder ~/.bash_profile:
export CC=gcc
Double check that you have gcc (probably a symlink) in your /usr/bin (most likely), and that it is pointing to a valid gcc compiler, ex: gcc -> llvm-gcc-4.2
You might have to restart your terminal for this change to take affect.
Ruby is not fully ready for LLVM compilation, this includes clang, there is at least one known isue with Fibers, but depending on LLVM version other problems might appear.
The right way to fix it is to get gcc-4.2 there are many ways for it and the best ones are described in requirements:
rvm get stable
rvm reload
rvm requirements run
rvm reinstall 1.9.3
Related
Hi I am learning React Native, I was able to build Android version successfully but here in the iOS version I am facing so many issues. I'm developing a Podcast application for both Android and iOS but when I'm trying to install cocoapods in my Application I am getting the following error,
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.3.1/ext/json/ext/generator
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20201214-42573-vm30sv.rb extconf.rb
creating Makefile
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.3.1/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.3.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
In file included from ./../fbuffer/fbuffer.h:5:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks')
1 error generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/json-2.3.1 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/json-2.3.1/gem_make.out
Hardware: Mac Mini
Can anyone help me in solving this issue. I'd like to install it with sudo gem install cocoapods rather than brew
You should not use Apple's Ruby installation. That installation exists solely for internal use by Apple itself.
Since you have specified in your question that you want to use Apple's Ruby installation, I am afraid there is nothing that can be done to fix the problem.
If, on the other hand, you are willing to use a different Ruby installation (installed by hand, with Homebrew, with ruby-install, with ruby-build, with RVM, asdf, or any other way), then the problem should not present itself in the first place.
For more information, see for example
macOS 10.15 Catalina Release Notes
PSA: Do not use system Ruby
Why you shouldn't use the System Ruby
If possible, do not use the ruby system version on Mac OSX
you need to install Xcode Command Line Tools。
command:
xcode-select --install
I am trying to install json ruby gem on Windows 7 32 System.
The local environment details are
D:\Environment\DevKit32Ruby200>gem -v
2.0.14
D:\Environment\DevKit32Ruby200>ruby -v
ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
D:\Environment\DevKit32Ruby200>rails -v
Rails 4.0.4
I have already tried following things
Downgrading system ruby gems version to 2.3.0 using
gem update --system 2.3.0
I have done proper setting of devkit and manually I added proper ruby directory path in config.yml file.
D:\Environment\DevKit32Ruby200>ruby dk.rb init
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.
D:\Environment\DevKit32Ruby200>ruby dk.rb install --force
[WARN] Updating (with backup) existing gem override for 'D:/Environment/ruby200new'
[WARN] Updating (with backup) DevKit helper library for 'D:/Environment/ruby200new'
I have also tried putting platform=ruby
gem install json --platform=ruby --verbose
The error I am getting while installing json is bellow.
D:\Environment\DevKit32Ruby200>gem install json
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.
D:/Environment/ruby200new/bin/ruby.exe extconf.rb
creating Makefile
make "DESTDIR="
generating generator-i386-mingw32.def
compiling generator.c
linking shared-object json/ext/generator.so
make "DESTDIR=" install
/usr/bin/install -c -m 0755 generator.so ./.gem.20170109-8336-qvgvzc/json/ext
make: execvp: /usr/bin/install: Permission denied
make: *** [install-so] Error 127
Gem files will remain installed in D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2 for inspection.
Results logged to D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2/ext/json/ext/generator/gem_make.out
There are 10's of questions are already tagged on this issue but none resolved.
Kindly help me to identify whats missing and why the error coming.
i386-mingw32 is a mountain of pain that'll never be fully supported, when I spent time on Windows I used to use a VirtualBox VM with ubuntu installed which shares a folder with the Windows host. I would edit the files with netbeans in windows and run the code in putty, the VM would basically be headless.
I actually did a lot of real work that way. If you want to do a "Hello World" rails app - OK - good luck even with that. How about an online development environment such as https://c9.io/ ?
But if you want to work, not just play around, set yourself up with an Ubuntu VM at the very least, or work in Ubuntu/MacOS at the very best.
Try this out:
Why don't you download the json .gem file from rubygems.org and install it directly using command
gem install json-x.x.x.gem
I'm trying to install sqlite3-ruby on Cygwin with gem install sqlite3-ruby -v x.x.x and I get the following error:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for fdatasync() in -lrt... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Does anyone know how to install sqlite3 for Ruby on Rails on Cygwin. As I understand it the SQLite RubyGem isn't actually a *Ruby*Gem, it's a "*C*Gem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it, so any help?
So this isn't a complete solution as I don't have a windows box and cygwin handy but the error message suggests that the linux utility fdatasync can't be found.
The tools linux man page can be found here
http://linux.die.net/man/2/fdatasync
Maybe find out if you have fdatasync installed correctly and try again.
I ran into this issue just now – the first time I wanted to install a Ruby gem
on my new Cygwin 64-bit system.
As I understand it the SQLite RubyGem isn't actually a RubyGem, it's a
"CGem", IOW it's written in C. This means it has to be compiled and linked
to the Ruby interpreter when you install it.
Cygwin actually provide a pre-compiled package which installs the sqlite3
gem files including the sqlite3_native.so linked library file. The name of
the package is ruby-sqlite3 and you can install it using Cygwin’s Setup.exe.
I personally like to use apt-cyg
when possible (not always) so I installed the package using:
apt-cyg install ruby-sqlite3
This package installs the appropriate gem files as can be seen by running
cygcheck -l ruby-sqlite3:
/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/gem.build_complete
/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/sqlite3/sqlite3_native.so
/usr/share/gems/gems/sqlite3-1.3.9/API_CHANGES.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/ChangeLog.cvs
/usr/share/gems/gems/sqlite3-1.3.9/CHANGELOG.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.rb
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.yml
/usr/share/gems/gems/sqlite3-1.3.9/Gemfile
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/constants.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/database.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/errors.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/pragmas.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/resultset.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/translator.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/value.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/version.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3.rb
/usr/share/gems/gems/sqlite3-1.3.9/LICENSE
/usr/share/gems/gems/sqlite3-1.3.9/Manifest.txt
/usr/share/gems/gems/sqlite3-1.3.9/README.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/tasks/faq.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/gem.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/native.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/vendor_sqlite3
I'm trying to install ruby on a Windows box and am having an issue. I have gotten up to this point when I start getting errors, and I'm completely new to anything other than PHP for web development. Help appreciated!
EDIT I'm following the instructions here for wamp:
http://www.alexbernard.fr/fichiers/blog/Installer-Ruby-On-Rails-sur-un-Wamp-Server.pdf
./gem install rails --include-dependencies
Output:
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
C:/wamp/ruby/bin/ruby.exe extconf.rb
creating Makefile
make
generating generator-x64-mingw32.def
compiling generator.c
make: x86_64-w64-mingw32-gcc: Command not found
make: *** [generator.o] Error 127
Gem files will remain installed in C:/wamp/ruby/lib/ruby/gems/2.0.0/gems/json-1.8.0 for inspection.
Results logged to C:/wamp/ruby/lib/ruby/gems/2.0.0/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
From the output shown above, I assume the following:
Installed Ruby 2.0.0 x64 (64bits)
Installed some DevKit from RubyInstaller page
Now, as explained here, for 64bits Ruby you need 64bits DevKit.
From the error in the output:
make: x86_64-w64-mingw32-gcc: Command not found
It is clear you didn't install the right DevKit.
Please remove the DevKit installed, download the correct one (as indicated in the link above and in RubyInstaller downloads page) and install again.
You will require to use ruby dk.rb install --force (note the --force option) to override the previous DevKit installation.
As for the the deprecation error, --include-dependencies is no longer required. I recommend you use as installation reference a modern Ruby/Rails guide.
You can go the RailsInstaller way to install Rails and all dependencies in one go without getting into such problems.
For me, the problem was that the DevKit binaries did not get added to the PATH. Make sure that (DEVKIT_FOLDER)\mingw\bin is on the path.
Because I read this answer with hope of fixing my problem, and found it did not help, here's how I resolved it:
--
Your error is:
make: x86_64-w64-mingw32-gcc: Command not found
--
The error means that you don't have access to the gcc/gc++ compiler on your PC.
You should therefore either locate, or download a version of the compiler to your system. I found installing the build tools located here solved the issue.
You just have to download those tools, then add them to the PATH var: set PATH=C:/path/to/your/ming64/location/;%PATH%;
This should build it for you.
A caveat -- whether you have the correct dependencies for a build to take place is another question entirely.
The exe is in rubydevkit\mingw\bin. Just add that to your path and json will build.
OS: Mac OS X 10.8.2
XCode: Latest with command line tools installed (version 4.6)
Rails: version 3.2.3
I was trying to generate the routes for a project I am working on (been doing that on regular basis), when I got an error message, with a recommendation that I do bundle install and bundle exec. I did, and this time around, the process broke off while compiling the JSON Gem (version 1.7.7).
Doing some research on StackOverflow, the recommendation was to update the XCode's command line tools, and I did, but that did not solve the problem.
I tried installing the JSON version 1.7.7 separately, and it failed, telling me to look for the error log in:
~/.rvm/gems/ruby-1.9.3-p125/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
Which reads:
/Users/mine/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
I looked for /usr/bin/gcc-4.2, and indeed, it's not there. But, when I do:
ls -l /usr/bin/gcc
Here's what I get:
lrwxr-xr-x 1 root wheel 12 Feb 14 15:49 /usr/bin/gcc -> llvm-gcc-4.2
How do I fix this problem?
I think the problem is that when you install the Xcode command line tools, gcc is sym-linked to llvm, and llvm can't always compile Ruby and gems correctly.
If you install autoconf, automake, and gcc directly (or through something like Homebrew), you should be able to fix the compiler errors.
The problem is that the gcc you used to compile your installed version of ruby got removed as part of the xcode upgrades. Using RVM rebuild your ruby (you might want to upgrade to the latest version as well). Once you do that, you should have no problem building gems with native extensions.