0

I previously installed rails with the preinstalled ruby that comes with mac. I have recently installed ruby through rvm.

I then did

  rails -v 

and got the following error

 kingsosina$ rails -v
 /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:298:in `to_specs': Could not find      'railties' (>= 0) among 5 total gem(s) (Gem::LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:309:in `to_spec'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'

What has gone wrong here? Do I need to gem install rails again?

my lastest output

 kingsosina$ which ruby
 /Users/kingsosina/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
 kingsosina$ which rails
 /Users/kingsosina/.rvm/gems/ruby-2.0.0-p353/bin/rails
 kingsosina$ which gem
 /Users/kingsosina/.rvm/rubies/ruby-2.0.0-p353/bin/gem
 kingsosina$ 

Does everything seem ok? and how does terminal know to reference this version of ruby instead of the pre-installed version on the mac, when i do ruby -v?

Samuel
  • 5,529
  • 5
  • 25
  • 39

2 Answers2

3

For what it's worth, the paths shown in your error output indicate that you're still referencing the OSX version of ruby. You'll want to enter the directory and type

rvm use X.X.X-pXXX

where X.X.X-pXXX is the ruby version that you want rvm to use. You can also add a file called .ruby-version with X.X.X-pXXX in it and rvm and other ruby version managers will switch to the appropriate version for you. Adding a .ruby-gemset file will also switch to the appropriate set of gems.

Finally, you'll need to make sure that the gems are installed in the rvm ruby/gemset combination. Putting that all together, to get started with the latest ruby and latest rails gem you would...

rvm install 2.0.0
rvm use 2.0.0
rvm gemset use --create my-project-gems
gem install rails
mpapis
  • 52,729
  • 14
  • 121
  • 158
AndyV
  • 3,696
  • 1
  • 19
  • 17
  • Hi. did rvm install and my terminal says it already installed. i then did **which rails** and the output is **kingsosina$ which rails /Users/kingsosina/.rvm/gems/ruby-2.0.0-p353/bin/rails** – Samuel Nov 22 '13 at 16:04
  • If that's the case then yes, I'd reinstall rails in this environment. – AndyV Nov 22 '13 at 16:40
  • what `which rails` says is that `rails` is in `PATH`, but the error says that something is wrong, either `GEM_HOME` was not set or the `rails` shebang is broken, you can check: `echo $GEM_HOME` and `head $(which rails)` – mpapis Nov 22 '13 at 17:34
  • @AndyV @mpapis does this look correct? I managed to get `ruby -v`, `rails -v` and `gem -v` to work accordingly `kingsosina$ which ruby /Users/kingsosina/.rvm/rubies/ruby-2.0.0-p353/bin/ruby kingsosina$ which rails /Users/kingsosina/.rvm/gems/ruby-2.0.0-p353/bin/rails kingsosina$ which gem /Users/kingsosina/.rvm/rubies/ruby-2.0.0-p353/bin/gem kingsosina$` – Samuel Nov 22 '13 at 19:46
  • Yes, those look like they're properly responding out of rvm rather than system ruby. – AndyV Nov 22 '13 at 21:41
  • just `which gem rails` does not answer all question, check: `echo $GEM_HOME` and `head $(which rails)` – mpapis Nov 22 '13 at 21:47
-1

Did you install newer version of ruby along with the rvm install? Do rvm list to find out what rubies your have installed. Then do rvm use <ruby-version-here> to select a ruby with rvm. Then you need to gem install rails again because its a new ruby. If you get a permission denied error trying to install gems try rvmsudo gem install rails.

DiegoSalazar
  • 13,361
  • 2
  • 38
  • 55
  • Hey. I don't think I did this **curl -L get.rvm.io | bash -s stable** Should I do **rvm install 2.0.0**? – Samuel Nov 22 '13 at 15:53
  • Yes, install ruby 2.0.0. That is preferred. After you install 2.0.0 try following my suggestion and if it doesn't work post any errors you get. – DiegoSalazar Nov 22 '13 at 15:56
  • downwoted because of the `rvmsudo` it is not needed and can only mess up things. – mpapis Nov 22 '13 at 17:33
  • I'd like to learn why, can you explain or provide sources? I use it because it works and sudo does not. According to this answer, it's pretty legit: http://stackoverflow.com/questions/5817555/rvmsudo-vs-sudo – DiegoSalazar Nov 22 '13 at 21:42