使用这个 SO 答案你如何在 rbenv 中使用多个 rails 版本?,我正在尝试使用 rbenv(而不是 rvm)设置环境来管理不同版本的 Ruby 和 Rails。答案首先说以这种方式安装链接到 ruby 版本的 Rails 版本。
RBENV_VERSION=1.9.3-p327 rbenv exec gem install rails --version 3.2.10
这对我有用。导轨安装。
按照它的说明,然后我尝试使用该版本的 rails 以这种方式创建一个新项目
RBENV_VERSION=1.9.3-p327 rbenv exec rails _3.10.2_ new newprojectname
那对我不起作用。我收到一条关于
.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (= 3.10.2) amongst [RedCloth-4.2.9, aaronh-chronic-0.3.9, abstract-1.0.0, actionmailer-3.2.10, actionmailer-3.0.4, actionpack-3.2.10, actionpack-3.0.4, activemodel-3.2.10, activemodel-3.2.9, activemodel-3.0.4, activerecord-3.2.10, activerecord-3.0.4, activeresource-3.2.10, activeresource-3.0.4, activesupport-3.2.10, activesupport-3.2.9, activesupport-3.0.4, addressable-2.3.2, arel-3.0.2, arel-2.0.10, bigdecimal-1.1.0, builder-3.0.4, builder-2.1.2, bundler-1.2.3, capybara-2.0.2, carrierwave-0.5.8, childprocess-0.3.6, coderay-1.0.8, cucumber-1.2.1, cucumber-rails-1.3.0, diff-lcs-1.1.3, erubis-2.7.0, erubis-2.6.6, factory_girl-4.1.0, ffi-1.2.0, formtastic-2.2.1, gherkin-2.11.5, hike-1.2.1, i18n-0.6.1, io-console-0.3, jist-1.3.1, journey-1.0.4, json-1.7.6, json-1.5.4, lesstile-1.1.0, libwebsocket-0.1.7.1, mail-2.4.4, mail-2.2.19, market_beat-0.2.0, method_source-0.8.1, mime-types-1.19, minitest-2.5.1, multi_json-1.5.0, nokogiri-1.5.6, polyglot-0.3.3, pry-0.9.10, pry-rails-0.2.2, rack-1.4.1, rack-1.2.5, rack-cache-1.2, rack-mount-0.6.14, rack-openid-1.3.1, rack-ssl-1.3.2, rack-test-0.6.2, rack-test-0.5.7, rails-3.2.10, rails-3.0.4, railties-3.2.10, railties-3.0.4, rake-10.0.3, rake-0.9.2.2, rdoc-3.9.4, rspec-2.12.0, rspec-core-2.12.2, rspec-expectations-2.12.1, rspec-mocks-2.12.1, rspec-rails-2.12.0, ruby-openid-2.2.2, rubygems-update-1.8.24, rubyzip-0.9.9, selenium-webdriver-2.27.2, slop-3.3.3, sprockets-2.2.2, sqlite3-1.3.6, sqlite3-ruby-1.3.3, thor-0.14.6, tilt-1.3.3, treetop-1.4.12, tzinfo-0.3.35, webrat-0.7.3, websocket-1.0.6, will_paginate-3.0.pre2, xpath-1.0.0] (Gem::LoadError)
from /Users/michaeljohnmitchell/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/michaeljohnmitchell/.rbenv/versions/1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from /Users/michaeljohnmitchell/.rbenv/versions/1.9.3-p327/bin/rails:22:in `<main>'
因此我尝试安装railties
gem install railties
有效
Successfully installed railties-3.2.10
1 gem installed
Installing ri documentation for railties-3.2.10...
Installing RDoc documentation for railties-3.2.10...
但是,尝试再次创建项目
RBENV_VERSION=1.9.3-p327 rbenv exec rails _3.10.2_ new newprojectname
创建了关于 railties 的相同错误消息
see error message above
我什至尝试再次安装 railties 但使用 RBENV 前缀
RBENV_VERSION=1.9.3-p327 rbenv exec gem install railties
它再次安装!但是,当我尝试创建新项目时,我收到了相同的错误消息。