Question

I tried to update Rails using:

sudo gem install rails --version 4.0
sudo gem install rails --version 4.0.0
sudo gem install rails -v 4.0
sudo gem install activesupport -v '4.0.0'

But, I always get the same error:

ERROR:  Error installing activesupport:
        activesupport requires Ruby version >= 1.9.3.

System Info:

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin11.4.2]
Rails 3.2.7

What could be the problem?

Update:

I found differences in terminals:

in aptana studio:

> gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.6
  - RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-11
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/kai/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

> gem list
*** LOCAL GEMS ***
actionmailer (3.2.7, 3.2.6)
actionpack (3.2.7, 3.2.6)
activemodel (3.2.7, 3.2.6)
activerecord (3.2.7, 3.2.6)
activeresource (3.2.7, 3.2.6)
activesupport (3.2.7, 3.2.6)
arel (3.0.2)
atomic (1.1.12)
bcrypt-ruby (3.0.1)
builder (3.0.4, 3.0.0)
bundler (1.3.5, 1.0.0)
capistrano (2.13.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.4.0, 1.3.3)
curb (0.7.12)
daemons (1.1.0)
devise (2.1.2)
erubis (2.7.0)
eventmachine (0.12.10)
execjs (1.4.0)
flickraw (0.9.6)
highline (1.6.16)
hike (1.2.1)
i18n (0.6.4, 0.6.1, 0.6.0)
journey (1.0.4)
jquery-rails (2.1.3, 2.1.1, 2.0.2)
json (1.7.5, 1.7.4, 1.5.1)
kgio (2.7.4)
mail (2.4.4)
mime-types (1.19)
minitest (4.7.5)
msgpack (0.3.9apple)
multi_json (1.7.9, 1.3.7, 1.3.6)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.6.2)
net-ssh-gateway (1.1.0)
orm_adapter (0.4.0)
patron (0.4.11)
pg (0.10.1)
polyglot (0.3.3)
rack (1.4.1, 1.2.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2, 0.6.1)
rails (3.2.7, 3.2.6)
railties (3.2.7, 3.2.6)
raindrops (0.10.0)
rake (10.0.3, 0.9.2.2)
rdoc (3.12)
ref (1.0.2)
ruby_protobuf (0.4.11)
rubygems-update (2.0.6)
sass (3.2.3, 3.2.1, 3.1.20)
sass-rails (3.2.5)
sinatra (1.2.0)
sprockets (2.1.3)
sqlite3 (1.3.6)
sqlite3-ruby (1.2.4)
thin (1.2.8)
thor (0.16.0, 0.15.4)
thread_safe (0.1.2)
tilt (1.3.3, 1.2.2)
treetop (1.4.12, 1.4.10)
tzinfo (0.3.37, 0.3.35, 0.3.33)
uglifier (1.2.7)
warden (1.2.1)

and so the ruby app with require 'activesupport' returns when start it:

/Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- activesupport (LoadError)
    from /Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/kai/Documents/Aptana Studio 3 Workspace/flickr_empty_project/app/app.rb:5:in `<main>'

in bash:

> gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.6
  - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin11.4.2]
  - INSTALLATION DIRECTORY: /Users/kai/.rvm/gems/ruby-2.0.0-p247
  - RUBY EXECUTABLE: /Users/kai/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/kai/.rvm/gems/ruby-2.0.0-p247/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-11
  - GEM PATHS:
     - /Users/kai/.rvm/gems/ruby-2.0.0-p247
     - /Users/kai/.rvm/gems/ruby-2.0.0-p247@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/


> gem list

*** LOCAL GEMS ***

actionmailer (4.0.0)
actionpack (4.0.0)
activemodel (4.0.0)
activerecord (4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.0)
arel (4.0.0)
atomic (1.1.12)
bigdecimal (1.2.0)
builder (3.1.4)
bundler (1.3.5)
bundler-unload (1.0.1)
erubis (2.7.0)
flickraw (0.9.6)
hike (1.2.3)
i18n (0.6.4)
io-console (0.4.2)
json (1.7.7)
mail (2.5.4)
mime-types (1.23)
minitest (4.3.2)
multi_json (1.7.9)
polyglot (0.3.3)
psych (2.0.0)
rack (1.5.2)
rack-test (0.6.2)
rails (4.0.0)
railties (4.0.0)
rake (10.1.0, 0.9.6)
rdoc (4.0.0)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)
sprockets (2.10.0)
sprockets-rails (2.0.0)
test-unit (2.0.0.0)
thor (0.18.1)
thread_safe (0.1.2)
tilt (1.4.1)
treetop (1.4.14)
tzinfo (0.3.37)
Was it helpful?

Solution

Hope this documentation will help you. Please see the link

Step 1:
 rvm get head (to get the latest version of rvm)

Step 2:
 rvm install 2.0.0 (to install ruby)

Step 3:
 rvm use 2.0.0

Step 4:
 rvm gemset create rails4

Step 5:
 gem install rails

OTHER TIPS

Installing any gem using sudo will try to install or overwrite the gems for the built-in Ruby. Don't try to install Rails into the Mac's system version of Ruby; Leave Apple's Ruby alone, and install a copy of Ruby into a sandbox using RVM or rbenv instead.

Apple installed Ruby for their own use, not for yours. You can use it of course, but if you want to have something more modern than the default, install something more recent.

If you installed a Ruby for your own use using RVM or rbenv into your home directory into a sandbox, you do not need to use sudo ever when adding gems because you should have ownership and full privileges to administer those files.

Gem doesn't always seem to use the same path your shell uses. Try running gem env to see the RUBY VERSION and RUBY EXECUTABLE gem is using.

If as I suspect gem is using the Mac OS X system default (1.8.x) you can try forcing the path for the gem command:

PATH=<path-to-correct-ruby>:$PATH gem env

where path-to-correct-ruby might be something like ~/.rmv/rubies/default.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top