为什么我需要“捆绑安装”每次使用 rvm 在 Rails 3.2.1 中重新启动后?
由于某种原因,每次重新启动计算机时,我都必须重做大量 Ruby on Rails 设置。我必须重做“捆绑安装”以安装 Gemfile 中的所有 gem,然后即使我通过 RVM 安装了 Rails,我也必须使用“gem installrails”重新安装 Rails。我从未在具有其他设置的另一台计算机上遇到过此问题,所以我不确定出了什么问题。
下面是一些终端输出,希望可以帮助人们调试出现的问题。
$ 导轨
此系统上当前未安装 Rails。要获取最新版本,只需键入:
$ sudo gem 安装rails
然后您可以重新运行“rails”命令。
$ rvm -v
rvm 1.10.2,作者:Wayne E. Seguin、Michal Papis [https://rvm.beginrescueend.com/]
$ rvm 信息
ruby-1.9.2-p290@demoapp:
系统: uname: "Darwin Jonathans-Mac-Pro.local 11.2.0 Darwin 内核版本 11.2.0: 2011 年 8 月 9 日星期二 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64" bash: “/bin/bash => GNU bash,版本 3.2.48(1)-release (x86_64-apple-darwin11)” zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"
rvm: 版本:“rvm 1.10.2,作者:Wayne E. Seguin、Michal Papis [https://rvm.beginrescueend.com/]” 更新:“11 小时 11 分 19 秒前”
红宝石: 翻译:“红宝石” 版本:“1.9.2p290” 日期: "2011-07-09" 平台:“x86_64-darwin11.2.0” 补丁级别:“2011-07-09 修订版 32553” full_version: "ruby 1.9.2p290 (2011-07-09 修订版 32553) [x86_64-darwin11.2.0]"
家园: 宝石:“/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp” 红宝石:“/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290”
二进制文件: 红宝石:“/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/bin/ruby” irb:“/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/bin/irb” 宝石:“/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/bin/gem” 耙子:“/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp/bin/rake”
环境: 小路: “/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp/bin:/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/jonc alhoun/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/joncalhoun/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin: /usr/X11/bin” GEM_HOME:“/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp” GEM_PATH:“/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp:/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@global” MY_RUBY_HOME:“/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290” IRBRC:“/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/.irbrc” 鲁比奥特:“” 宝石集:“demoapp”
$ gem -v
16年8月1日
$ gem which (这不会返回任何奇怪的东西)
在我 gem 安装rails 后: $ 轨道 -v
Rails 3.2.1
我猜这是我的 gem 设置有问题,但我不知道在哪里挖掘。如果您需要更多信息来帮助我,我可以提供,并感谢任何有时间提供帮助的人。
For some reason everytime I reboot my computer I have to redo a lot of Ruby on Rails setup. I have to redo the "bundle install" to install all of the gems in my Gemfile, and then I have to reinstall rails with "gem install rails" even though I installed rails through RVM. I have never had this issue on another computer with other setups so I'm not sure what is going wrong.
Below is some terminal output that will hopefully help someone debug what is going wrong.
$ rails
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
$ rvm -v
rvm 1.10.2 by Wayne E. Seguin , Michal Papis [https://rvm.beginrescueend.com/]
$ rvm info
ruby-1.9.2-p290@demoapp:
system:
uname: "Darwin Jonathans-Mac-Pro.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"rvm:
version: "rvm 1.10.2 by Wayne E. Seguin , Michal Papis [https://rvm.beginrescueend.com/]"
updated: "11 hours 11 minutes 19 seconds ago"ruby:
interpreter: "ruby"
version: "1.9.2p290"
date: "2011-07-09"
platform: "x86_64-darwin11.2.0"
patchlevel: "2011-07-09 revision 32553"
full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]"homes:
gem: "/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp"
ruby: "/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290"binaries:
ruby: "/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/bin/ruby"
irb: "/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/bin/irb"
gem: "/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/bin/gem"
rake: "/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp/bin/rake"environment:
PATH: "/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp/bin:/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/joncalhoun/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
GEM_HOME: "/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp"
GEM_PATH: "/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@demoapp:/Users/joncalhoun/.rvm/gems/ruby-1.9.2-p290@global"
MY_RUBY_HOME: "/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290"
IRBRC: "/Users/joncalhoun/.rvm/rubies/ruby-1.9.2-p290/.irbrc"
RUBYOPT: ""
gemset: "demoapp"
$ gem -v
1.8.16
$ gem which (this doesnt returns anything oddly)
After I gem install rails:
$ rails -v
Rails 3.2.1
I am guessing this is something wrong with my gem setup but I don't know enough to know where to dig. If you need any more information to help I can provide it and thank you for anyone who has the time to help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将 Rails 3.2.1 与 RVM 结合使用,通常不需要手动运行“gem install”。
我的猜测是,您已经通过 RVM 安装了 ruby 解释器(或者可能您没有在 RVM 中安装 ruby),或者您还没有配置 RVM 以选择默认的 ruby 解释器。
您可以通过以下方式配置默认 ruby(如果您使用的是 1.9.3-p0):
然后,1.9.3-p0 ruby 将在登录 shell 后生效。您可以通过以下方式检查正在使用哪个 ruby 解释器:
如果您配置正确,它应该打印如下:
在后期捆绑器时代的 Rails 应用程序中,您只需要运行捆绑器来安装所需的 gem(到 RVM 中的当前 gemset) 。如果不创建gemset,将使用全局gemset。运行:
将安装您需要的所有 gem。
现在,由于 RVM 自动选择带有名为“global”的 gemset 的 1.9.3-p0,因此您无需在启动后重新安装(就像我一样)。
您可以选择为 Rails 应用程序创建 gemset 并配置每个目录的基础。要为每个应用程序配置默认的 gemset/ruby 解释器,请检查 RVM 站点。
If you're using Rails 3.2.1 with RVM, you usually do not need to run 'gem install' manually.
My guess is, you've installed ruby interpreter via RVM (or possibly, you haven't installed ruby in RVM), or you haven't configured RVM to select the default ruby interpreter.
You can configure default ruby by (if you're using 1.9.3-p0):
Then, the 1.9.3-p0 ruby will in effect after logging in to the shell. You can check which ruby interpreter is in use, by:
If you correctly configured, it should be print like:
In the post bundler-age rails app, you just need to run bundler to install required gems (onto the current gemset in RVM). If you don't create gemset, global gemset will be used. Run:
will install all gems you need.
Now, since RVM automatically select 1.9.3-p0 with gemset named 'global', you don't need to re-install after boot (as I do).
You can optionally create gemset for the rails app and configure per-directory basis. To configure default gemset/ruby interpreter per application, check the RVM site.