Ruby on rails 找不到有效的gem安装activerecord-sqlite3-adapter
我是Ruby的初学者。 我跟着上面的步骤走 安装RubyonRails并按照youtube教程创建了一个名为“Blog”的项目 但是每当我使用命令Ruby on rails 找不到有效的gem安装activerecord-sqlite3-adapter,ruby-on-rails,ruby,ruby-on-rails-3,sqlite,Ruby On Rails,Ruby,Ruby On Rails 3,Sqlite,我是Ruby的初学者。 我跟着上面的步骤走 安装RubyonRails并按照youtube教程创建了一个名为“Blog”的项目 但是每当我使用命令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:
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)
这发生在我的笔记本电脑和个人电脑上,它们都使用Windows7。
我试图运行命令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)
如果有人能解决我的问题,我将不胜感激。您不能将
activerecord-sqlite3-adapter
作为gem安装,因为这个适配器已经包含在activerecord中了。问题不在于activerecord-sqlite3-adapter
,而在于您没有将sqlite3
作为Gem捆绑包的一部分(错误消息最后告诉我们:“sqlite3不是捆绑包的一部分。”)
要修复它,请先将其添加到您的文件中:
# in your Gemfile
gem 'sqlite3'
然后从命令行运行:
$ bundle install
确保
sqlite3
正确安装并显示在您的Gem捆绑包中,所有内容都应该正常工作。我遇到了与您提出的问题相同的问题,经过多次尝试和错误后,我找到了一些简单的步骤来修复它
首先,将以下内容添加到您的文件中:
gem 'sqlite3', '1.3.5'
然后在控制台中运行:
bundle install
然后应该正常运行Ruby 2.0与sqlite3有问题,无法运行。如果需要使用sqlite3,则必须降级到1.9.3。我没有这方面的文档链接,但是我知道如果你降级到1.9.3你会没事的。我会看看是否能找到链接。gem'sqlite3'已经在我的gem文件中。当我运行命令“bundle install”时,它告诉我“您的bundle已完成!请使用
bundle show[gemname]
查看捆绑gem的安装位置”,但我的gem bundle中仍然缺少sqlite3。我同意他的最后评论。我的gemfile中有平台:ruby-do-gem'sqlite3'end,它安装了gem-sqlite3-gem。我能够从irb中的自述示例中看到它的工作原理,所以我知道该部分正在工作。当sqlite3不是默认值时,它是rails的旧版本。我会尝试使用最新版本的rails。他们在那里包括了一个示例应用程序,所以您在运行该应用程序时应该没有问题。祝你好运。除非你在对话中添加了新内容,否则复制粘贴答案并没有真正的帮助。它可能看起来像是复制粘贴,但上面的答案没有使用gem版本,直到我添加了它,它才对我起作用。只是想和大家分享我解决问题的具体步骤