MacOSX 上的 RVM、Gemset、Bash - 在升级过程中我做了什么?

发布于 2024-12-29 21:40:01 字数 1152 浏览 1 评论 0原文

每次我在 Mac OSX Lion 中打开新终端时,rails 都不会加载。这是在我升级到 ruby​​ 1.9.3 和 Rails 3.2 之后 - 所以我做了很多配置,但不确定我搞砸了什么。它曾经工作得很好。

如果我在启动时加载一个新终端,然后输入:

rvm

就可以了。

如果我输入,

ruby -v

我会得到正确的(1.9.3),

但如果我输入rails -v,我会收到一条错误消息:

/Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [rake-0.9.2.2, rake-0.9.2] (Gem::LoadError)
    from /Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1208:in `gem'
    from /usr/bin/rails:18:in `<main>'

如果我输入:

   rvm use 1.9.3p0@rails32 --default

这使得rails正常工作,但仅在该终端窗口中 - 即使是终端中的新选项卡,rails 给出错误 - 每当我启动时,如何让它接受 gemset/config 作为全局默认值?我有:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

在我的 .bash_profile 中。

我在升级过程中对我的配置做了什么/错过了什么?这看起来很简单,但我没有发现它。

Every time I open a new terminal in Mac OSX Lion, rails isn't loaded. This is after I upgraded to ruby 1.9.3 and rails 3.2 - so I was doing a lot of configuring but not sure what I've screwed up. It used to work fine.

If I load a new terminal on startup, and type:

rvm

that works.

If I type

ruby -v

I get the correct (1.9.3)

but if I type rails -v, I get an error saying:

/Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [rake-0.9.2.2, rake-0.9.2] (Gem::LoadError)
    from /Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /Users/userishere/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1208:in `gem'
    from /usr/bin/rails:18:in `<main>'

If I type:

   rvm use 1.9.3p0@rails32 --default

That makes rails work as normal, but only in that terminal window -even a new tab in terminal, rails gives errors - how do I get it to accept that gemset/config as the global default whenever I start up? I have:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

in my .bash_profile.

What have I done to my config / missed in my upgrade? It seems like something simple, but I'm not spotting it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事与诗 2025-01-05 21:40:01

我只是使用命令 rvm 1.9.2-p290@mybranch --default 切换了我自己的默认 rvm (并不是说我在命令中没有“use”)

然后,如果您打开新的终端窗口或选项卡并输入 rvm list 您应该会在它使用的 ruby​​ 版本旁边看到一个 => 。我看到这个:

   ree-1.8.7-2010.02 [ x86_64 ]
   ruby-1.8.7-p302 [ x86_64 ]
   ruby-1.9.1-p378 [ x86_64 ]
   ruby-1.9.2-p0 [ x86_64 ]
   ruby-1.9.2-p136 [ x86_64 ]
   ruby-1.9.2-p180 [ x86_64 ]
=> ruby-1.9.2-p290 [ x86_64 ]

我喜欢在命令提示符旁边查看我正在使用哪个 rvm 版本和 gemset。在您列出的加载 RVM 函数的行之前的 .bash_profile 中,添加以下内容:

PS1="\$(~/.rvm/bin/rvm-prompt ivgs) $PS1

"根据我的提示:ruby-1.9.2@myapp

I just switched my own default rvm by using the command rvm 1.9.2-p290@mybranch --default (not that I didn't have 'use' in the command)

Then, if you open a new terminal window or tab and type rvm list you should see a => next to the ruby version it's using. I see this:

   ree-1.8.7-2010.02 [ x86_64 ]
   ruby-1.8.7-p302 [ x86_64 ]
   ruby-1.9.1-p378 [ x86_64 ]
   ruby-1.9.2-p0 [ x86_64 ]
   ruby-1.9.2-p136 [ x86_64 ]
   ruby-1.9.2-p180 [ x86_64 ]
=> ruby-1.9.2-p290 [ x86_64 ]

I like to see which rvm version and gemset I'm using next to my command prompt. In your .bash_profile right before the line you listed that loads the RVM function, add this:

PS1="\$(~/.rvm/bin/rvm-prompt i v g s) $PS1"

Which prepends this to my prompt: ruby-1.9.2@myapp

黒涩兲箜 2025-01-05 21:40:01

rvm 1.9.3-p0@rails32 --默认仅将其设置为当前终端窗口工作,一旦我添加另一个或退出并返回,它又恢复为不工作。

我通过将 .rvmrc 文件添加到我的应用程序目录来修复此问题。现在它加载宝石集和ruby 版本正确。

根据:
http://seanbehan.com/mac-os-x/installing-and-using-rvm-on-mac-os-x-creating-gemsets-and-reverting-to-original-environment/

rvm 1.9.3-p0@rails32 --default only set it working for the current terminal window, once I added another or exited and came back it was back to not working.

I fixed this by adding a .rvmrc file to my app directory. It now loads the gemset & ruby version correctly.

As per:
http://seanbehan.com/mac-os-x/installing-and-using-rvm-on-mac-os-x-creating-gemsets-and-reverting-to-original-environment/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文