0

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
Community
  • 1
  • 1
aalab002
  • 357
  • 2
  • 4
  • 12

3 Answers3

3

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!

aalab002
  • 357
  • 2
  • 4
  • 12
1

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.

boomslang
  • 118
  • 1
  • 1
  • 6
  • `Ayman$ sudorvm gem install rails -bash: sudorvm: command not found` – aalab002 Jan 19 '14 at 16:01
  • Just tried it with `rvmsudo` instead of `sudorvm` and that worked and prompted for a password and started initializing but then returning the same error message as before. – aalab002 Jan 19 '14 at 16:06
  • I just tried it again and now I get `ERROR: While executing gem ... (Gem::RemoteFetcher::UnknownHostError) no such name (http://api.rubygems.org/quick/Marshal.4.8/minitest-4.7.5.gemspec.rz)` – aalab002 Jan 19 '14 at 17:39
1

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
chrisan
  • 4,152
  • 4
  • 28
  • 32
  • I downloaded rbenv but can't seem to find the command to install rails. All docs tell me to simply run `gem install rails` and that brings back the same error message. – aalab002 Jan 19 '14 at 16:10
  • when I try `rbenv install rails` it tells me `ruby-build definition not found: rails` so I list available versions: `Ayman$ rbenv install --list Available versions: 1.8.6-p383 1.8.6-p420 1.8.7-p249 1.8.7-p302 1.8.7-p334 1.8.7-p352 1.8.7-p357 1.8.7-p358 1.8.7-p370 1.8.7-p371 1.8.7-p374 1.8.7-p375 1.9.1-p378 1.9.1-p430 1.9.2-p0 1.9.2-p180 1.9.2-p290 1.9.2-p318 1.9.2-p320 1.9.2-p326 1.9.3-dev 1.9.3-p0 1.9.3-p125 1.9.3-p194 1.9.3-p286` – aalab002 Jan 19 '14 at 16:17
  • ` 1.9.3-p327 1.9.3-p362 1.9.3-p374 1.9.3-p385 1.9.3-p392 1.9.3-p429 1.9.3-p448 1.9.3-p484 1.9.3-preview1 1.9.3-rc1 2.0.0-dev 2.0.0-p0 2.0.0-p195 2.0.0-p247 2.0.0-p353 2.0.0-preview1 2.0.0-preview2 2.0.0-rc1 2.0.0-rc2 2.1.0 2.1.0-dev 2.1.0-preview1 2.1.0-preview2 2.1.0-rc1 2.2.0-dev` – aalab002 Jan 19 '14 at 16:21
  • ` jruby-1.5.6 jruby-1.6.3 jruby-1.6.4 jruby-1.6.5 jruby-1.6.5.1 jruby-1.6.6 jruby-1.6.7 jruby-1.6.7.2 jruby-1.6.8 jruby-1.7.0 jruby-1.7.0-preview1 jruby-1.7.0-preview2 jruby-1.7.0-rc1 jruby-1.7.0-rc2 jruby-1.7.1 jruby-1.7.10 jruby-1.7.2 jruby-1.7.3 jruby-1.7.4 jruby-1.7.5 jruby-1.7.6 jruby-1.7.7 jruby-1.7.8 jruby-1.7.9 maglev-1.0.0 maglev-1.1.0-dev maglev-2.0.0-dev mruby-dev rbx-1.2.4 rbx-2.0.0 rbx-2.0.0-dev rbx-2.0.0-rc1 rbx-2.1.0 rbx-2.1.1 rbx-2.2.0 rbx-2.2.1 rbx-2.2.2 rbx-2.2.3` – aalab002 Jan 19 '14 at 16:21
  • ree-1.8.6-2009.06 ree-1.8.7-2009.09 ree-1.8.7-2009.10 ree-1.8.7-2010.01 ree-1.8.7-2010.02 ree-1.8.7-2011.03 ree-1.8.7-2011.12 ree-1.8.7-2012.01 ree-1.8.7-2012.02 topaz-dev – aalab002 Jan 19 '14 at 16:22
  • @aalab002 did you install a ruby yet with rbenv? You also need to do `brew install ruby-build` so you can build rubies. Once you have that, try running `rbenv versions` if you dont see a ruby, try `rbenv install 2.1.0` then `rbenv rehash` then `rbenv global 2.1.0` followed by `gem install rails` and finally another `rbenv rehash` – chrisan Jan 19 '14 at 16:52
  • @aalab002 I updated the original post with instructions – chrisan Jan 19 '14 at 16:56
  • I updated the original question with my terminal log. The problem appears to be related to my permissions: `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` – aalab002 Jan 19 '14 at 17:21
  • I tried `sudo gem install rails` again now the error message has changed to: `Ayman$ sudo gem install rails ERROR: While executing gem ... (Gem::RemoteFetcher::UnknownHostError) no such name (http://api.rubygems.org/quick/Marshal.4.8/minitest-4.7.5.gemspec.rz)` – aalab002 Jan 19 '14 at 17:26