【问题标题】:Could not find a valid gem install activerecord-sqlite3-adapter找不到有效的 gem 安装 activerecord-sqlite3-adapter
【发布时间】:2013-05-06 22:43:59
【问题描述】:

我是 Ruby 的初学者。 我按照http://rubyonrails.org/download 和 安装 Ruby on rails 并按照 youtube 教程创建了一个名为“Blog”的项目。 http://www.youtube.com/watch?v=UQ8_VOGj5H8

但是每当我使用命令rails s时,它都会报错:

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integ
ration.rb:214:in `block in replace_gem': Please install the sqlite3 adapter: `ge
m install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add
it to Gemfile.) (LoadError)

这发生在我的笔记本电脑和 PC 上,它们都使用的是 Windows 7。 我尝试运行命令gem install activerecord-sqlite3-adapter,但随后出现错误。

C:\Users\Ouye\blog>gem install activerecord-sqlite3-adapter
ERROR:  Could not find a valid gem 'activerecord-sqlite3-adapter' (>= 0) in any
repository
ERROR:  Possible alternatives: activerecord-jdbcsqlite3-adapter, activerecord-sq
lserver-adapter, activerecord-bq-adapter, activerecord-simpledb-adapter, activer
ecord-mysql2-adapter

我尝试了上述所有替代方法并更新了我的捆绑包安装,其中一些替代方法有效,而另一些无效。在我尝试了上述所有替代方法并运行“rails s”后,我仍然收到告诉我安装 sqlite3 适配器的相同错误。

这就是我的 gem 文件的样子

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'sqlite3'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

这就是 gem 中的所有捆绑包

Gems included by the bundle:
  actionmailer (3.2.13)
  actionpack (3.2.13)
  activemodel (3.2.13)
  activerecord (3.2.13)
  activeresource (3.2.13)
  activesupport (3.2.13)
  arel (3.0.2)
  builder (3.0.4)
  bundler (1.3.5)
  coffee-rails (3.2.2)
  coffee-script (2.2.0)
  coffee-script-source (1.6.2)
  erubis (2.7.0)
  execjs (1.4.0)
  hike (1.2.2)
  i18n (0.6.1)
  journey (1.0.4)
  jquery-rails (2.2.1)
  json (1.7.7)
  mail (2.5.3)
  mime-types (1.23)
  multi_json (1.7.3)
  polyglot (0.3.3)
  rack (1.4.5)
  rack-cache (1.2)
  rack-ssl (1.3.3)
  rack-test (0.6.2)
  rails (3.2.13)
  railties (3.2.13)
  rake (10.0.4)
  rdoc (3.12.2)
  sass (3.2.9)
  sass-rails (3.2.6)
  sprockets (2.2.2)
  thor (0.18.1)
  tilt (1.4.1)
  treetop (1.4.12)
  tzinfo (0.3.37)

如果有人能解决我的问题,我将不胜感激。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 sqlite


    【解决方案1】:

    您不能将activerecord-sqlite3-adapter 安装为 gem,因为此适配器已包含在 ActiveRecord 中。问题不在于activerecord-sqlite3-adapter,而在于您没有将sqlite3 作为Gem 捆绑包的一部分(错误消息最后告诉我们:“sqlite3 不是捆绑包的一部分。")

    要修复它,请先将其添加到您的 Gemfile:

    # in your Gemfile
    gem 'sqlite3'
    

    然后从命令行运行:

    $ bundle install
    

    确保sqlite3 正确安装并显示在您的 Gem 捆绑包中,并且一切正常。

    【讨论】:

    • gem 'sqlite3' 已经在我的 gem 文件中了。当我运行命令“bundle install”时,它告诉我“你的包已完成!使用bundle show [gemname] 查看捆绑的 gem 的安装位置”,但我的 Gem 包中仍然缺少 sqlite3
    • 我同意他最后的评论。我的gemfile中有平台:ruby do gem'sqlite3' end,它安装了gem sqlite3 gem。我可以从 irb 中的自述文件示例中看到它的工作原理,所以我知道这部分工作正常。当 sqlite3 不是默认值时,它是旧版本的 rails。我会尝试使用最新版本的rails。他们在其中包含了一个示例应用程序,因此您应该没有问题让它运行。祝你好运。
    【解决方案2】:

    我遇到了与您提出的相同的问题,经过大量试验和错误,我找到了一些简单的步骤来解决它。

    首先,添加到您的 Gemfile:

    gem 'sqlite3', '1.3.5'
    

    然后在你的控制台中运行:

    bundle install
    

    然后你应该正常进行

    【讨论】:

    • 复制粘贴答案并没有真正的帮助,除非您在对话中添加新内容。
    • 这似乎是复制粘贴,但上面的答案没有使用 gem 版本,直到我添加它才对我有用。只是想分享我为解决问题所做的确切步骤
    【解决方案3】:

    Ruby 2.0 与 sqlite3 有问题,无法运行。如果你需要使用 sqlite3,你必须降级到 1.9.3。我没有相关文档的链接,但我知道如果你降级到 1.9.3,你会没事的。我看看能不能找到链接。

    【讨论】:

      猜你喜欢
      • 2013-03-06
      • 2013-06-03
      • 2011-02-10
      • 2016-11-17
      • 1970-01-01
      • 2011-08-09
      • 2012-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多