Evan
Evan

Reputation: 665

How to point Rails to the right Ruby install

I've been fighting with my Mac OS X 10.8 installed version of Ruby and tried to move to a .rvm install in order to keep everything up to date.

After going through all the documentation on the RVM website, here are some outcomes:

~$ which ruby
/Users/localadmin/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
~$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]
~$ which rails
/usr/bin/rails
~$ rails -v
-bash: /usr/bin/rails: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory

I'm not exactly sure what's causing this. I'm expecting that Rails is trying to use the system Ruby version, which isn't what I set as default in RVM.

I've read that it could be a .gemrc problem, but I can't seem to find a .gemrc file in my home directory. I can't seem to find any references to rails in my .rvm directory, so I'm thinking maybe when I did "gem install rails", "gem" was actually the one affiliated with my system Ruby.

Upvotes: 0

Views: 430

Answers (2)

Remear
Remear

Reputation: 1937

When using RVM, you pretty much NEVER use sudo for anything. The only common exception to this I've found is when installing the Passenger module.

That means all operations you want to perform on or with gems, rubies, rubygems, or RVM itself should NOT be performed with sudo.

Also make sure to do rvm use [RUBY] --default to make certain you're always using a ruby other than the system ones.

Upvotes: 0

Evan
Evan

Reputation: 665

Sorry to answer my own question, and I'd be happy if it gets deleted, but the solution was fairly annoying.

I had been installing rails with:

sudo gem install rails

I guess this took me out of the userspace in which my RVM installation sat

gem install rails

installed rails properly and now I get "Rails 3.2.9" as the outcome to rails -v

Could anyone shine any light on why this happened?

Upvotes: 1

Related Questions