Install Rails 3 on OSX with RVM

早过忘川 提交于 2019-11-28 04:12:04
marshally

Older versions of rvm had a bug that can cause your ruby versions to get crosswired because the OS can cache executable paths for the which command (particularly if you are using zsh). See this long, detailed, mind blowing post by Yehuda Katz on the subject.

What I had to do this morning:

rvm update && rvm reload # update rvm
rvm gemset delete rails3 # delete old gemset
rvm install 1.9.2
rvm use 1.9.2
rvm gemset create rails3
rvm use 1.9.2@rails3
which ruby          # check to be sure the ruby interpretter is properly set to 1.9.2
hash -r             # if ruby interpretter is not pointing to 1.9.2
gem install rails
which rails         # check to be sure we are using rvm version of rails

Note: On newer versions of rvm, you will have to use rvm get stable instead of rvm update

You don't need to use sudo when installing gems with rvm. If you follow the directions here to get RVM installed, you should be able to just do rvm use 1.9.2; gem install rails --version 3.0.0.

You don't have to specify version 3. If you have 1.9.2-p0, it will automatically get rails 3 when you rvm gem install rails 3. note: no sudo. I think when you use sudo it makes it use the system-installed ruby. If you think you need sudo, use rvmsudo.

Things probably got messy because you were following guides based on the pre-stable release of rails, which involved many other things. If you like, you can try uninstalling rvm and re-doing everything. It really isn't all that difficult.

Remember, you need 1.9.2, 1.9.1 won't work.

curl -O http://rvm.beginrescueend.com/releases/rvm-install-head
sh rvm-install-head
rvm install 1.9.2-p0

# also remember to edit your bash profile and add the required lines

# verify that 1.9.2-p0 shows up there
rvm list

# makes it so you're using it, and sets it as the default
rvm use 1.9.2-p0 --default

# verify this happened. should have => 1.9.2-p0 in the list
rvm list

# verify the version
ruby --version

# should automatically get 3.0
# `rvm gem install` installs it for every single installed ruby version
# in my experience
gem install rails

When you did rvm gem install, I think it installs it for every ruby version you have registered with rvm (at least it happened in my experience), so my assumption is that it was trying to force install rails 3 for an older ruby installation, which was missing the required gems.

Take it easy, not many commands are required. If you find yourself having to do 'hacks' or workarounds, then you're doing it wrong. Thankfully it's easy to start over. To remove rvm, just do rm -rfv ~/.rvm and also rm ~/.rvmrc if it's there.

Let me know how it goes.

working through this myself as new user mac osx blah blah

seems like a cache directory doesn't get made, try mkdir $HOME/.rvm/gems/cache

so far so good after that...

I am running into the same problem (tried uninstalling and installing like Blaenk suggested)

rvm -v rvm 1.0.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]

ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]

gem install rails ERROR: While executing gem ... (Errno::ENOENT) No such file or directory - /Users/pragnesh/.rvm/gems/ruby-1.9.2-p0/cache/activesupport-3.0.0.gem

After doing "rvm update && rvm reload" rvm got updated to 1.04 (instead of 1.02 which I got via the recommended GIT install yesterday!?) it worked nicely.

The solution worked for me, with a few tweeks:

Instead of using rvm update, I had to use rvm rubygems. Then, after doing all the work from post 2, I had to execute bundle install and I entered rvm use 1.9.2@rails3 to my .rvmrc file. Everything now works like a charm, even when starting a new shell or terminal session. The full list of commands I used is:

>> NEW >> rvm rubygems
rvm reload                 # update rvm
rvm gemset delete rails3   # delete old gemset
rvm install 1.9.2
rvm use 1.9.2
rvm gemset create rails3
rvm use 1.9.2@rails3
which ruby                 # check to be sure the ruby interpretter is properly set to 1.9.2
>> DID NOT NEED >> hash -r # if ruby interpretter is not pointing to 1.9.2
gem install rails
which rails                # check to be sure we are using rvm version of rails
>> NEW >> bundle install
>> NEW >> cat 'rvm use 1.9.2@rails3' > .rvmrc

Followed these instructions, and found them very useful for rvm installation. Hope they work for you.

http://adventuresincoding.com/2010/01/taking-the-helm-of-ruby-with-ruby-version-manager/

Doing this after the rvm update and reload worked for me:

rm -rf .bundle && bundle install
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!