macos 使用 RVM 在 OSX 上安装 Rails 3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3648392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install Rails 3 on OSX with RVM
提问by Kevin
Trying to install the new Rails 3 release on OSX 10.6.
尝试在 OSX 10.6 上安装新的 Rails 3 版本。
Have never touched Ruby or Rails on this machine since purchased.
自从购买以来,从未在这台机器上接触过 Ruby 或 Rails。
I was able to get rvm and get Ruby 1.9.2. installed. From there, I am stuck.
我能够获得 rvm 并获得 Ruby 1.9.2。安装。从那里,我被困住了。
I tried:
我试过:
rvmsudo gem install rails -v 3.0.0
sudo gem install rails --pre
sudo gem install rails
sudo gem update rails
And I get the same result error each time:
我每次都得到相同的结果错误:
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - /Users/kevin/.rvm/gems/ruby-1.9.2-head@rails3/cache/activesupport-3.0.0.gem
If I do gem list, it says LOCAL GEMSand doesn't list anything.
如果我做 gem list,它会显示LOCAL GEMS而没有列出任何东西。
I have read a few walkthroughs but honestly none of them address this issue and its kind of pissing me off. Why is this so difficult to install? Would love to learn it if someone could help me get it running.
我已经阅读了一些演练,但老实说,他们都没有解决这个问题,这让我很生气。为什么安装这么难?如果有人可以帮助我运行它,我很想学习它。
I was trying to follow this:
我试图遵循这个:
http://eddorre.com/posts/installing-rails-3-beta-4-using-rvm
http://eddorre.com/posts/installing-rails-3-beta-4-using-rvm
and this:
还有这个:
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard
Which is actually linked from the ROR guides website. Am I missing dependencies? How do I get them in?
这实际上是从 ROR 指南网站链接的。我是否缺少依赖项?我如何让他们进来?
If I do rails -v
I get:
如果我这样做,rails -v
我会得到:
rails -v
/Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate'
from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
回答by 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 whichcommand (particularly if you are using zsh). See this long, detailed, mind blowing postby Yehuda Katz on the subject.
较旧版本的 rvm 有一个错误,可能会导致您的 ruby 版本交叉连接,因为操作系统可以缓存which命令的可执行路径(尤其是在您使用 zsh 时)。请参阅Yehuda Katz 关于该主题的这篇长篇、详细、令人兴奋的帖子。
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
注意:在较新版本的 rvm 上,您必须使用rvm get stable
而不是rvm update
回答by AboutRuby
回答by Jorge Israel Pe?a
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
.
您不必指定版本 3。如果您有 1.9.2-p0,当您使用rvm gem install rails 3
. 注意:没有 sudo。我认为当您使用 sudo 时,它会使用系统安装的 ruby。如果您认为需要 sudo,请使用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.
事情可能变得一团糟,因为您遵循了基于 Rails 稳定版的指南,其中涉及许多其他事情。如果您愿意,可以尝试卸载 rvm 并重新执行所有操作。这真的不是那么困难。
Remember, you need 1.9.2, 1.9.1 won't work.
请记住,您需要 1.9.2,1.9.1 不起作用。
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.
当您这样做时rvm gem install
,我认为它会为您在 rvm 注册的每个 ruby 版本安装它(至少在我的经验中发生过),所以我的假设是它试图为较旧的 ruby 安装强制安装 rails 3,但缺少了所需的宝石。
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.
放轻松,不需要太多命令。如果您发现自己必须进行“黑客攻击”或变通方法,那么您就做错了。值得庆幸的是,重新开始很容易。要删除 rvm,只需执行rm -rfv ~/.rvm
并且rm ~/.rvmrc
如果它在那里。
Let me know how it goes.
让我知道事情的后续。
回答by flummox
working through this myself as new user mac osx blah blah
我自己作为新用户 mac osx 来解决这个问题,等等
seems like a cache directory doesn't get made, try mkdir $HOME/.rvm/gems/cache
好像没有建立缓存目录,试试 mkdir $HOME/.rvm/gems/cache
so far so good after that...
到目前为止一切都很好……
回答by Hans W.
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:
而不是使用rvm update
,我不得不使用rvm rubygems
. 然后,在完成第二篇文章的所有工作后,我必须执行bundle install
并进入rvm use 1.9.2@rails3
我的.rvmrc
文件。现在一切都像魅力一样,即使在启动新的 shell 或终端会话时也是如此。我使用的完整命令列表是:
>> 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
回答by Pragnesh Vaghela
I am running into the same problem (tried uninstalling and installing like Blaenk suggested)
我遇到了同样的问题(尝试像 Blaenk 建议的那样卸载和安装)
rvm -v rvm 1.0.2 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]
rvm -v rvm 1.0.2 by Wayne E. Seguin ([email protected]) [ http://rvm.beginrescueend.com/]
ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
ruby -v ruby 1.9.2p0 (2010-08-18 修订版 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
gem install rails 错误:执行 gem 时 ... (Errno::ENOENT) 没有这样的文件或目录 - /Users/pragnesh/.rvm/gems/ruby-1.9.2-p0/cache/activesupport-3.0.0.gem
回答by itsme
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.
执行“rvm update && rvm reload”后,rvm 更新到 1.04(而不是我昨天通过推荐的 GIT 安装获得的 1.02!?)它运行良好。
回答by pdenlinger
Followed these instructions, and found them very useful for rvm installation. Hope they work for you.
遵循这些说明,发现它们对 rvm 安装非常有用。希望他们为你工作。
http://adventuresincoding.com/2010/01/taking-the-helm-of-ruby-with-ruby-version-manager/
http://adventuresincoding.com/2010/01/taking-the-helm-of-ruby-with-ruby-version-manager/
回答by jschorr
Doing this after the rvm update and reload worked for me:
在 rvm 更新和重新加载后执行此操作对我有用:
rm -rf .bundle && bundle install