操作系统是 Ubuntu 12.04,64 位。
铁轨新手。Ruby 相对较新。遵循 ruby.railstutorial.org 教程,第 3 章。
本教程已更新为使用 ruby 2.0.0 和 Rails 4.0.0.rc1。以前 gemfile 指定 Rails 3.2.13 而不是指定 Ruby 版本。移至教程中的最新 Gemfile ruby 2.0.0 和 Rails 4.0.0.rc1 后,运行 rails 命令时出现以下错误。这里的例子是Rails 服务器
user@machine:~/bin/railslearn/sample_app$ rails server
/home/paul/bin/railslearn/sample_app/config/application.rb:7:in `require': cannot load such file -- active_resource/railtie (LoadError)
from /home/paul/bin/railslearn/sample_app/config/application.rb:7:in `<top (required)>'
from /home/paul/.rvm/gems/ruby-2.0.0-p195@railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `require'
from /home/paul/.rvm/gems/ruby-2.0.0-p195@railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:78:in `block in <top (required)>'
from /home/paul/.rvm/gems/ruby-2.0.0-p195@railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `tap'
from /home/paul/.rvm/gems/ruby-2.0.0-p195@railstutorial_rails_4_0/gems/railties-4.0.0.rc1/lib/rails/commands.rb:75:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我确实从Rails 得到了一些想法: 找不到 railties,概述如下,但还没有找到解决方法。
这是详细信息。
昨天(在我的浏览器中)第 3 章的 Gemfile 如下。一切正常。
$ cat Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
# gem 'guard-rspec', '1.2.1'
# gem 'guard-spork', '1.2.0'
# gem 'childprocess', '0.3.6'
# gem 'spork', '0.9.2'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
# gem 'launchy', '2.1.0'
# gem 'rb-fsevent', '0.9.1', :require => false
# gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
今天早上教程中的 Gemfiles 使用的是 ruby 2.0.0 和 rails 4.0.0.rc1。我想让这个设置正常工作,所以我与更新的教程没有冲突。新建 Gemfile 如下。
$ cat Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0.rc1'
group :development, :test do
gem 'sqlite3', '1.3.7'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.0.0'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.0.rc1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
end
首先,我将 Gemfile 中的 ruby 版本更改为 ruby '1.9.2',因为那是我正在运行的,并且认为我在更新包时出错。我没有做笔记。
然后在 Gemfile 中将 ruby 版本改回 '2.0.0' 并:
$ rvm install 2.0.0
$ rvm use 2.0.0 --default
$ bundle update
$ bundle install
现在我得到了使用 rails 命令无法加载 railtie错误。
从Rails:找不到 railties,我尝试了以下
$ gem uninstall railties
Select gem to uninstall:
1. railties-4.0.0.rc1
2. railties-3.2.13
3. All versions
> 2
You have requested to uninstall the gem:
railties-3.2.13
rails-3.2.13 depends on railties (= 3.2.13)
If you remove this gem, these dependencies will not be met.
Y # uninstall railties-3.2.13
仍然收到错误
$ gem uninstall rails # to uninstall rails-3.2.13
$ gem uninstall railties # to also uninstall railties-4.0.0.rc1
$ rvm reinstall 2.0.0
$ rvm 2.0.0 --default
$ bundle update # using the Gemfile with ruby 2, rails 4
$ bundle install
$ gem list | grep rail
coffee-rails (4.0.0)
jquery-rails (2.2.1)
rails (4.0.0.rc1)
railties (4.0.0.rc1)
rspec-rails (2.13.1)
sass-rails (4.0.0.rc1)
sprockets-rails (2.0.0.rc4)
仍然收到错误
回顾第一章教程中的原始设置(现在针对 ruby 2、rails 4 进行了更新。)
$ rvm use 2.0.0@railstutorial_rails_4_0 --create --default
$ gem update --system 2.0.0
$ gem install rails --version 4.0.0.rc1 --no-ri --no-rdoc
$ bundle update # using Gemfile with ruby 2, rails 4
$ bundle install
仍然收到错误
啊!!!
有任何想法吗?