1

Hi i am new to ruby on rails

I have install the rvm on my mac

The default ruby is 1.8.7

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0]
$ rails -v
Rails 2.3.18
$ gem -v
2.2.2

When i try to use ruby 2.1.0 the rails i guess failed to load

$ rvm use 2.1.0
Using /usr/local/rvm/gems/ruby-2.1.0
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin10.0]
$ rails -v
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'railties' (>= 0) among 14 total gem(s) (Gem::LoadError)
    from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
    from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
    from /usr/local/rvm/rubies/ruby-2.1.0/bin/rails:22:in `<main>'
$ gem -v
2.2.2

and i dont know how to solve it

here is the rvm list know

$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p484]
[ruby-]2.0.0-p195
[ruby-]2.0.0[-p353]
[ruby-]2.1.0
[ruby-]2.1-head
ruby-head

# GoRuby
goruby

# Topaz
topaz

# TheCodeShop - MRI experimental patches
tcs

# jamesgolick - All around gangster
jamesgolick

# Minimalistic ruby implementation - ISO 30170:2012
mruby[-head]

# JRuby
jruby-1.6.8
jruby-1.7.6
jruby-1.7.9
jruby[-1.7.10]
jruby-head

# Rubinius
rbx-2.0.0
rbx-2.1.1
rbx[-2.2.4]
rbx-head

# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]

# Kiji
kiji

# MagLev
maglev[-head]
maglev-1.0.0

# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head

# Opal
opal

# IronRuby
ironruby[-1.1.3]
ironruby-head

rvm info

rvm info

ruby-2.1.0:

  rvm:
    version:      "rvm 1.25.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "2 days 6 hours 43 minutes 42 seconds ago"
    path:         "/usr/local/rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.1.0p0"
    date:         "2013-12-25"
    platform:     "x86_64-darwin10.0"
    patchlevel:   "2013-12-25 revision 44422"
    full_version: "ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin10.0]"

  homes:
    gem:          "/usr/local/rvm/gems/ruby-2.1.0"
    ruby:         "/usr/local/rvm/rubies/ruby-2.1.0"

  binaries:
    ruby:         "/usr/local/rvm/rubies/ruby-2.1.0/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ruby-2.1.0/bin/irb"
    gem:          "/usr/local/rvm/rubies/ruby-2.1.0/bin/gem"
    rake:         "/usr/local/rvm/rubies/ruby-2.1.0/bin/rake"

  environment:
    PATH:         "/usr/local/rvm/gems/ruby-2.1.0/bin:/usr/local/rvm/gems/ruby-2.1.0@global/bin:/usr/local/rvm/rubies/ruby-2.1.0/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-2.1.0"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-2.1.0:/usr/local/rvm/gems/ruby-2.1.0@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-2.1.0"
    IRBRC:        "/usr/local/rvm/rubies/ruby-2.1.0/.irbrc"
    RUBYOPT:      ""
    gemset:       ""
ntan
  • 2,195
  • 7
  • 35
  • 56

3 Answers3

2

Looks like you have rails installed in global gemset. What you can do is:

  1. Remove rails from global gemset.
  2. Then install Rails in a separate gemset. But, as far as I know, Rails 2.3.18 is not compatible with Ruby 2.1.0.

Here's more or less accurate example of how to do it:

rvm use 2.1.0@global         # switching to global gemset
gem uninstall rails          # removing rails gem
rvm use 2.1.0@rails --create # creating a separate gemset for rails
gem install rails            # installing rails

In order to use RVM effectively, you need to consult [gemsets documentation].1

That's it!

Update. I believe you've installed RVM under sudo command. In order to fix this follow these steps:

rvm implode                             # remove RVM
\curl -sSL https://get.rvm.io | bash    # install it again
rvm install 2.1.0                       # install Ruby 2.1.0
rvm use 2.1.0@rails --create --default  # create default gemset for Rails
gem install rails                       # install Rails itself

In order to avoid problems with permissions, I strongly suggest you not to use sudo during installation of gems.

marvelousNinja
  • 1,510
  • 9
  • 15
  • gem unistall rails ERROR: While executing gem ... (Gem::CommandLineError) Unknown command unistall Unistall does not work for me – ntan Feb 12 '14 at 15:37
  • You've a typo. It's `uninstall`, but not `unistall`. – marvelousNinja Feb 12 '14 at 15:40
  • Sorry rvm use 2.1.0@rails --create gives me mkdir: /usr/local/rvm/gems/ruby-2.1.0@rails: Permission denied – ntan Feb 12 '14 at 15:45
  • Looks like you installed `rvm` under `sudo` command. I believe you need to reinstall it completely. I will update my answer. – marvelousNinja Feb 12 '14 at 16:24
  • i wiil procced without sudo and get back to you – ntan Feb 12 '14 at 16:43
  • thanks for your patient, your suggestions help me install right.The only thing i did not manage to achive is install rails with docs because keep stuck on rails ri documentation and install it withou it – ntan Feb 13 '14 at 09:44
0
  • Restart Terminal/Console
  • Go to your project location
  • Run rvm use ruby-2.1.0 --default

Now, it will show the current rvm by running rvm list

Then, all the installed rvm versions will be shown along with the currently selected one with a * symbol.

Rajesh Omanakuttan
  • 6,788
  • 7
  • 47
  • 85
0

Run following command:

sudo gem install rails
bundle install
rails s
Dheer
  • 773
  • 1
  • 6
  • 16