【问题标题】:Getting error on using rake db:create command (Ruby on Rails)使用 rake db:create 命令时出错(Ruby on Rails)
【发布时间】:2012-09-30 11:32:46
【问题描述】:

我刚开始使用 ruby​​ on rails,创建了一个新的 rails 项目文件夹。 现在我正在尝试使用 rake db:create 命令,但出现以下错误。 请帮忙。

NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /home/samsung/ruby/blog/config/../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/samsung/ruby/blog/config/../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/lib/ruby/vendor_ruby/1.8/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/lib/ruby/vendor_ruby/1.8/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/lib/ruby/vendor_ruby/1.8/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/lib/ruby/vendor_ruby/1.8/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/lib/ruby/vendor_ruby/1.8/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/lib/ruby/vendor_ruby/1.8/rubygems/source_index.rb:91.
WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /usr/lib/ruby/vendor_ruby/rake/rdoctask.rb
Please install RDoc 2.4.2+ to generate documentation.
rake aborted!
no such file to load -- sqlite3

Tasks: TOP => db:create
(See full trace by running task with --trace)

【问题讨论】:

  • 请告诉我们您使用的是什么操作系统以及如何安装 Ruby,以便我们更好地帮助您。

标签: ruby-on-rails ruby sqlite rake


【解决方案1】:

您需要确保将要使用的 gem 添加到您的 gemfile 中:

gem 'sqlite3'

然后,从应用根目录中的命令行安装 gem:

bundle install

这将导致它们被自动需要,修复以下错误:

no such file to load -- sqlite3

【讨论】:

    【解决方案2】:

    错误出现在输出的最后一行:

    no such file to load -- sqlite3
    

    显示找不到sqlite3文件。这可能是因为未安装 sqlite3 gem。尝试使用以下命令找到它:

    gem list sqlite3
    

    如果没有出现,请使用以下命令安装它:

    gem install sqlite3
    

    我认为您可能还安装了旧版本的 Ruby。我建议使用 RVM 并安装更新版本的 Ruby,例如 1.9,而不是 1.8。有关如何执行此操作的信息,请参阅 this page

    【讨论】:

    • 我使用 rvm 安装了新版本的 ruby​​。但是它已安装在 /usr/share 中,旧版本仍在 /usr/lib 中
    • 当我检查 ruby​​ --version 它只显示旧版本。
    • @Abhinav,这就是 rvm 的重点。它允许您在不同版本的 ruby​​ 之间切换,等等。无论如何,请执行rvm use 1.9.2 --default 或您想在 rvm 中使用的任何 ruby​​ 版本。假设您安装了其他版本的 ruby​​。使用rvm list查看您拥有的版本,然后使用其他命令切换到您想要的任何版本。
    • 是的,使用rvm use 1.9.3 --default 切换到默认的Ruby 版本。
    猜你喜欢
    • 2013-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-28
    • 2011-10-10
    • 2015-08-05
    • 2012-11-23
    相关资源
    最近更新 更多