2014-02-12 167 views
1

嗨,我是新來的Ruby on Rails的Ruby on Rails的RVM使用

我有我的Mac上安裝RVM

默認紅寶石1.8.7

$ ruby -v 
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0] 
$ rails -v 
Rails 2.3.18 
$ gem -v 
2.2.2 

當我嘗試使用Ruby 2.1.0我想加載失敗

$ rvm use 2.1.0 
Using /usr/local/rvm/gems/ruby-2.1.0 
$ ruby -v 
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin10.0] 
$ rails -v 
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'railties' (>= 0) among 14 total gem(s) (Gem::LoadError) 
    from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec' 
    from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem' 
    from /usr/local/rvm/rubies/ruby-2.1.0/bin/rails:22:in `<main>' 
$ gem -v 
2.2.2 

軌道,我不知道如何解決它

這裏是RVM列表知道

$ rvm list known 
# MRI Rubies 
[ruby-]1.8.6[-p420] 
[ruby-]1.8.7[-p374] 
[ruby-]1.9.1[-p431] 
[ruby-]1.9.2[-p320] 
[ruby-]1.9.3[-p484] 
[ruby-]2.0.0-p195 
[ruby-]2.0.0[-p353] 
[ruby-]2.1.0 
[ruby-]2.1-head 
ruby-head 

# GoRuby 
goruby 

# Topaz 
topaz 

# TheCodeShop - MRI experimental patches 
tcs 

# jamesgolick - All around gangster 
jamesgolick 

# Minimalistic ruby implementation - ISO 30170:2012 
mruby[-head] 

# JRuby 
jruby-1.6.8 
jruby-1.7.6 
jruby-1.7.9 
jruby[-1.7.10] 
jruby-head 

# Rubinius 
rbx-2.0.0 
rbx-2.1.1 
rbx[-2.2.4] 
rbx-head 

# Ruby Enterprise Edition 
ree-1.8.6 
ree[-1.8.7][-2012.02] 

# Kiji 
kiji 

# MagLev 
maglev[-head] 
maglev-1.0.0 

# Mac OS X Snow Leopard Or Newer 
macruby-0.10 
macruby-0.11 
macruby[-0.12] 
macruby-nightly 
macruby-head 

# Opal 
opal 

# IronRuby 
ironruby[-1.1.3] 
ironruby-head 

RVM信息

RVM信息

ruby-2.1.0: 

    rvm: 
    version:  "rvm 1.25.17 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]" 
    updated:  "2 days 6 hours 43 minutes 42 seconds ago" 
    path:   "/usr/local/rvm" 

    ruby: 
    interpreter: "ruby" 
    version:  "2.1.0p0" 
    date:   "2013-12-25" 
    platform:  "x86_64-darwin10.0" 
    patchlevel: "2013-12-25 revision 44422" 
    full_version: "ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin10.0]" 

    homes: 
    gem:   "/usr/local/rvm/gems/ruby-2.1.0" 
    ruby:   "/usr/local/rvm/rubies/ruby-2.1.0" 

    binaries: 
    ruby:   "/usr/local/rvm/rubies/ruby-2.1.0/bin/ruby" 
    irb:   "/usr/local/rvm/rubies/ruby-2.1.0/bin/irb" 
    gem:   "/usr/local/rvm/rubies/ruby-2.1.0/bin/gem" 
    rake:   "/usr/local/rvm/rubies/ruby-2.1.0/bin/rake" 

    environment: 
    PATH:   "/usr/local/rvm/gems/ruby-2.1.0/bin:/usr/local/rvm/gems/[email protected]/bin:/usr/local/rvm/rubies/ruby-2.1.0/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" 
    GEM_HOME:  "/usr/local/rvm/gems/ruby-2.1.0" 
    GEM_PATH:  "/usr/local/rvm/gems/ruby-2.1.0:/usr/local/rvm/gems/[email protected]" 
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-2.1.0" 
    IRBRC:  "/usr/local/rvm/rubies/ruby-2.1.0/.irbrc" 
    RUBYOPT:  "" 
    gemset:  "" 
+0

追加的'RVM info'輸出到你的問題。這告訴我們你的RVM/Ruby環境是如何配置的。 –

+0

你有沒有用'bundle install'來更新你的新寶石版本的寶石集? –

+0

請參考:http://stackoverflow.com/questions/9212116/rails-could-not-find-railties –

回答

2

看起來你已經安裝在global寶石軌道。你可以做的是:

  1. global gemset中刪除導軌。
  2. 然後在一個單獨的gemset中安裝Rails。但據我所知,Rails 2.3.18與Ruby 2.1.0不兼容。

下面是如何做到這一點或多或少準確的例子:

rvm use [email protected]   # switching to global gemset 
gem uninstall rails   # removing rails gem 
rvm use [email protected] --create # creating a separate gemset for rails 
gem install rails   # installing rails 

爲了有效地使用RVM,您需要諮詢[gemsets文檔。 1

就是這樣!

更新。我相信你已經在sudo命令下安裝了RVM。爲了解決這個問題請按照下列步驟操作:

rvm implode        # remove RVM 
\curl -sSL https://get.rvm.io | bash # install it again 
rvm install 2.1.0      # install Ruby 2.1.0 
rvm use [email protected] --create --default # create default gemset for Rails 
gem install rails      # install Rails itself 

爲了避免與權限的問題,我強烈建議你不要安裝寶石的過程中使用sudo

+0

gem unistall rails 錯誤:執行gem時(Gem :: CommandLineError) 未知的命令unistall Unistall對我不起作用 – ntan

+0

你有一個錯字。它是'卸載',但不是'unistall'。 – marvelousNinja

+0

對不起rvm使用[email protected] --create給我mkdir:/usr/local/rvm/gems/[email protected]rails:權限被拒絕 – ntan

0
  • 重新啓動終端/主機
  • 轉到您的項目位置
  • 立即運行rvm use ruby-2.1.0 --default

,它會通過運行rvm list

然後,所有已安裝的RVM顯示當前RVM版本將與當前選定的符號一起顯示,並帶有*符號。

+0

它適合你嗎? –

+0

我重新安裝紅寶石和導軌,並重新開始。 – ntan

0

運行以下命令:

sudo gem install rails 
bundle install 
rails s