Install Rails Failed on OSX 10.8.4 - ruby-on-rails

I always failed to install rails on my new Air with OSX 10.8.4, even I succeed installed ruby2, Command Line Tool of XCode, it still prompts some error when I try to install rails.
I found lots solutions from the Internet, but they all don't work on my issue, I'm completely confused, doesn't any can help me? I'll really appreciate!!!
localhost:myapp zerocool$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
localhost:myapp zerocool$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:24:in `<main>'
Gem files will remain installed in /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12 for inspection.
Results logged to /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12/ext/gem_make.out

I ran into this issue today and it seems that my download of ruby-2.0.0 did not work properly. I would recommend trying rvm reinstall 2.0.0 followed by gem install rails.

Finally, I got the solution! Run rvm implodeļ¼Œand use rm to delete /etc/rvmrc and ~/.rmvrc, restart your mac, and you can use gem install rails to install rails successfully.

First I installed gcc via homebrew:
installing gcc on mavericks using brew
brew tap homebrew/dupes
brew install apple-gcc42
Then I symlinked the newly installed apple-gcc42
into my /usr/bin folder
cd /usr/bin
sudo mv gcc gcc_mavs sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 gcc
Credits: https://coderwall.com/p/lqpp8w

I had this same error when running against ruby-2.0.0-p195, but updating to ruby-2.0.0-p247 (the current RVM default for 2.0.0) fixed it.

Related

How to install ruby-odbc gem on M1 Mac

I am trying to get a rails project running on an M1 mac.
I have to use ruby 2.6.2 and rails 5.2.3
I am using rbenv 1.1.2 and homebrew 3.0
When I run bundle install, I get this error
An error occurred while installing ruby-odbc (0.99999), and Bundler cannot continue.
Make sure that `gem install ruby-odbc -v '0.99999'` succeeds before bundling.
So then I run gem install ruby-odbc -v '0.99999'
This leads to another error
ERROR: Error installing ruby-odbc:
ERROR: Failed to build gem native extension.
current directory: /Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/ruby-
odbc-0.99999/ext
/Users/david.lee/.rbenv/versions/2.6.2/bin/ruby -I
/Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/2.6.0 -r ./siteconf20210208-46271-1tguvxe.rb
extconf.rb
checking for version.h... no
checking for sql.h... no
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/david.lee/.rbenv/versions/2.6.2/bin/$(RUBY_BASE_NAME)
--with-odbc-dir
--without-odbc-dir
--with-odbc-include
--without-odbc-include=${odbc-dir}/include
--with-odbc-lib
--without-odbc-lib=${odbc-dir}/lib
ERROR: sql.h not found
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/ruby-odbc-0.99999/mkmf.log
When I stackoverflow this error, I get this post which tells me to brew install unixodbc, so I do that and try to bundle install again, which gives me the same error.
All the stackoverflow posts related to sql.h files not being installed do not solve my issue.
HOW DO I INSTALL THIS GEM?
Thanks to a co-worker, I got this resolved.
You need to install the gem while pointing it to the unixodbc directory
This was the line that installed it for me
gem install ruby-odbc -- --with-odbc-dir=/opt/homebrew/Cellar/unixodbc/2.3.9
To find your unixodbc path, run brew info unixodbc
That will give you the path and your version number of unixodbc. Then you put the path and version number in the appropriate spot
gem install ruby-odbc -- --with-odbc-dir=put your path and version number of unixodbc here
None of the above solutions worked for me when I had this error. This is what worked for me:
bundle config set build.ruby-odbc --with-odbc-dir=/opt/homebrew/Cellar/unixodbc/2.3.11
Per this StackOverflow post
If you need this to work while running the bundle command, do the following:
bundle config build.odbc --with-odbc-dir=$(brew --prefix unixodbc)

Error Installing Rails 5.2.3 on Ubuntu 18.04

I'm trying to install Rails 5.2.3 on Ubuntu 18.04 PC using Ruby version -2.5.5 and during the installation I'm facing this error.
$ gem install rails -v 5.2.3
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /home/amani/.rvm/gems/ruby-2.5.5/gems/nokogiri-1.10.4/ext/nokogiri
/home/amani/.rvm/rubies/ruby-2.5.5/bin/ruby -I /home/amani/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190831-23754-eu6kq8.rb extconf.rb
checking if the C compiler accepts ... *** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/amani/.rvm/rubies/ruby-2.5.5/bin/$(RUBY_BASE_NAME)
--help
--clean
/home/amani/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/amani/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /home/amani/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /home/amani/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /home/amani/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:416:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/amani/.rvm/gems/ruby-2.5.5/extensions/x86_64-linux/2.5.0/nokogiri-1.10.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/amani/.rvm/gems/ruby-2.5.5/gems/nokogiri-1.10.4 for inspection.
Results logged to /home/amani/.rvm/gems/ruby-2.5.5/extensions/x86_64-linux/2.5.0/nokogiri-1.10.4/gem_make.out
These are the error messages on terminal.
I just looked at your terminal log and realized that you are using RVM (Ruby version manager) as your ruby manager. The catch here is that RVM seems to be heavyweight as it manages not just your ruby version but also your ruby gems. A better option for you should be to use rbenv (Ruby environment), which manages just your ruby version and Bundler which manages ruby gems.
This way you will rarely run into conflicts where RVM and Bundler will be doing the same thing (managing your ruby gems), since rails installation depends on Bundler.
Here's a simple command built-in that will remove RVM and its related directories from your system:
rvm implode
In order to remove the final trace of rvm, you need to remove the rvm gem, too:
gem uninstall rvm
If you've made modifications to your PATH you might want to pull those, too. Check your .bashrc, .profile and .bash_profile files, among other things.
You may also have an /etc/rvmrc file, or one in your home directory ~/.rvmrc that may need to be removed as well.
When you are done with the removal of RVM and all of its files and directories, follow this guide How To Install Ruby on Rails with rbenv on Ubuntu 18.04 to install a fresh copy of Ruby on Rails with rbenv on your Ubuntu machine.
If you still run into any issue relating to bundler while using rbenv, simply follow the instruction below:
You need to simply install an update for RubyGems Package Manager locally. To do this, run
gem update --system
If you don't have bundler version 2 installed locally, then run
gem install bundler
And then finally run
bundler update --bundler
That's all.
I hope this helps.

Can't install Rails on my system

I keep getting the following error. I have rvm 1.25.17 (stable), ruby 2.1.0p0 revision 44422. Also, I checked my Xcode install and I think it's up to date (3.2 in /Developer and 5.0.2 in /Applications). At some point, an error told me that my Xcode might not be installed. I'm getting back into programming after a long break and am at a loss. Just trying to get setup on some Ruby on Rails...
Fetching: atomic-1.1.14.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/ecualombian/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/ecualombian/.rvm/rubies/ruby-2.1.0/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/lib
/Users/ecualombian/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/ecualombian/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
from /Users/ecualombian/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:840:in `try_run'
from extconf.rb:26:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/ecualombian/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/atomic-1.1.14 for inspection.
Results logged to /Users/ecualombian/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-12/2.1.0-static/atomic-1.1.14/gem_make.out
From XCode 5.0.1 onwards, you can install commandline tools from the terminal. Here's the command, please run this on your Terminal:
xcode-select --install
Once it's installed, try installing the gems again.
Basically atomic gem expects you to have developer tools like gcc 4.2 which you can install view brew or simply install XCode command like tools, reinstall ruby via rvm and then install rails.
You are probably missing command line tools for Xcode, that are required for gcc and make. Install the same from Xcode-> Preferences-> Downloads, or from the command line with xcode-select --install, and then retry installing Rails.

Failed to build native gem extension - Rails Install

I followed the instructions on the thread here but I still have the following error message:
Ayman$ rails -v
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Ayman$ gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:26:in `<main>'
Gem files will remain installed in /Users/Ayman/.rvm/gems/ruby-2.0.0-p353/gems/atomic-1.1.14 for inspection.
Results logged to /Users/Ayman/.rvm/gems/ruby-2.0.0-p353/gems/atomic-1.1.14/ext/gem_make.out
Ayman$
I am on the latest version of gems, running ruby 2.0.0, and Mac 10.8.
Any clue on what I am doing wrong?
Update
So I installed Xcode Command Line Tool per the following and am still recieving the following error message:
Ayman$ sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/Ayman/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:26:in `<main>'
Gem files will remain installed in /Users/Ayman/.rvm/rubies/ruby-2.0.0- p353/lib/ruby/gems/2.0.0/gems/atomic-1.1.14 for inspection.
Results logged to /Users/Ayman/.rvm/rubies/ruby-2.0.0- p353/lib/ruby/gems/2.0.0/gems/atomic-1.1.14/ext/gem_make.out
Ayman$
UPDATE TWO
Followed rbenv install below per the following:
Ayman$ brew update
Updated Homebrew from 8e60080c to e7a77f80.
==> Updated Formulae
reposurgeon
Ayman$ brew install rbenv ruby-build
Warning: rbenv-0.4.0 already installed
Warning: ruby-build-20140110.1 already installed
Ayman$ echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
Ayman$ ~/.bash_profile
-bash: /Users/Ayman/.bash_profile: Permission denied
Ayman$ rbenv install 2.1.0
Downloading ruby-2.1.0.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/9e6386d53f5200a3e7069107405b93f7
Installing ruby-2.1.0...
Installed ruby-2.1.0 to /Users/Ayman/.rbenv/versions/2.1.0
Ayman$ rbenv rehash
Ayman$ rbenv global 2.1.0
Ayman$ gem install rails bundler --no-ri --no-rdoc
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/Ayman/.rvm/gems/ruby-2.0.0-p353/gems/atomic- 1.1.14/test/test_atomic.rb
I solved the problem.
Turns out I was using an outdated version of gems.
Once I upgraded my gems to the latest version it worked fine.
Thanks everyone!
Try rvmsudo to use your rvm and have root privileges, maybe like this:
rvmsudo gem install rails
EDIT
I meant 'rvmsudo', not 'sudorvm'. Sorry for the mistake, I was on a phone.
There is always rbenv where you can skip all the hassle of sudo and permissions. Everything local to the user. Why rbenv?
brew update
brew install rbenv ruby-build
# if you dont have the init in your profile run the following:
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
source ~/.bash_profile
# install a ruby
rbenv install 2.1.0
# you need to rehash after installing a ruby version or a global gem
rbenv rehash
# this will set 2.1.0 as your default ruby version in shell
rbenv global 2.1.0
# now try installing rails
gem install rails bundler --no-ri --no-rdoc
rbenv rehash

Unable to install Rails extconf.rb failed

I'm new to Ruby on Rails, and I'm getting the below error when I'm installing it.
Please note, I have installed the latest Xcode and installed command line tools, and I'm using OSX 10.8.4. I've installed Ruby 2.0.0 as well.
-bash-3.2$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:24:in `<main>'
Gem files will remain installed in /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12 for inspection.
Results logged to /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12/ext/gem_make.out
I had similar problem and it gets solved by installing command line tools:
xcode-select --install
The symlinking did not solve the problem for me. I uninstalled my ruby that I previously had installed using rvm by typing rvm uninstall ruby-2.0.0 and then I typed rvm requirements. This command found that I needed a few other things, such as gcc46. It's strange that the gcc compiler was needed, even though I had installed the xcode command line tools, and gcc was most definitely installed on my system.
So, if none of the usual methods are working, give rvm requirements a shot!
I guess it's a same problem with this question.
Try sudo ln -s /usr/bin/{llvm-,}gcc-4.2 and gem install rails again.
By the way, you're in your own home directory, you don't have to use sudo.
I just ran into this with ruby 2.5.3 and was able to install cairo by calling:
PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig gem install cairo -v '1.15.2'
Took a while to find something that worked, as I already had the command line tools installed, and am using asdf not rvm.
Thanks to this thread for helping with the fix: https://github.com/ruby-gnome2/ruby-gnome2/issues/259#issuecomment-59751807

Resources