我需要帮助。我是编程新手,对学习 rubyonrails 很感兴趣。我使用在 ubuntu 社区页面上找到的软件在 ubuntu 12.10 上安装了上述软件。安装后,我尝试运行命令 rake db:migrate,但出现以下错误,请帮忙。
luke@luke-pc:~/www/railsapp$ rake db:migrate
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /home/luke/www/railsapp/vendor/rails/railties/lib/rails/gem_dependency.rb:21.
NOTE: Gem::SourceIndex#initialize is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#initialize called from /home/luke/www/railsapp/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100.
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:91.
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:91.
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:91.
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:91.
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:91.
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:91.
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/home/luke/www/railsapp/Rakefile:8:in `<top (required)>'
(See full trace by running task with --trace)
答案1
看起来这个例子中有两个过时的宝石(?)分别称为Gem::SourceIndex#add_spec
和rake/rdoctask
。
如果rake
将其替换为rdoc/task
,我认为它将会解决问题。
我们的问题(我在尝试运行书籍示例时遇到了同样的问题)是如何用 rdoc 替换 rake 函数。你能用 rdoc 代替 rake 吗?也许值得一试;但是,我还没有时间去做。
当我遇到您的问题时,我正打算先研究一下 rdoc。希望有人能给出答案,但我想您至少会想知道有人在研究这个问题。
答案2
经过更多工作之后,看起来打印出来的不是错误而是信息。
弃用是让一个命令消失或逐步淘汰,在这种情况下是在将来(2011-11-1,我们正在运行的 rails 版本的未来)。
运行“Learning Rails”中的一些示例,我发现我收到了所有关于弃用的警告,但是程序做它们应该做什么。创建目录和文件等。
打印输出警告称,2011 年 11 月 1 日以后发布的 rails 版本中,弃用的功能将不再起作用,并给出了如何替换功能的建议。
换句话说,继续运行书中的示例,只要您的软件版本不是太新,它们就可能起作用。
否则,升级到 rails 3 并避免所有无用的弃用警告(并且祝你好运在所有警告打印输出中找到真正的错误消息。)
另外,将您的教程升级到 rails 3