找不到有效的gem install activerecord-sqlite3-adapter

Ou *_* Ye 7 ruby sqlite ruby-on-rails ruby-on-rails-3

我是Ruby的初学者.我按照http://rubyonrails.org/download上的步骤操作并在rails 上安装Ruby,并按照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)
Run Code Online (Sandbox Code Playgroud)

这发生在我的笔记本电脑和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
Run Code Online (Sandbox Code Playgroud)

我尝试了上面的所有替代方案并更新了我的捆绑安装,一些替代方案有效,有些则没有.在我尝试了上面的所有替代方案并运行"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'
Run Code Online (Sandbox Code Playgroud)

这就是宝石中的所有捆绑

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)
Run Code Online (Sandbox Code Playgroud)

如果有人能解决我的问题,我将非常感激.

Arm*_*n H 18

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

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

# in your Gemfile
gem 'sqlite3'
Run Code Online (Sandbox Code Playgroud)

然后从命令行运行:

$ bundle install
Run Code Online (Sandbox Code Playgroud)

确保sqlite3正确安装并显示在Gem包中,一切都应该有效.

  • gem'sqlite3'已经在我的gem文件中了.当我运行命令"bundle install"时,它告诉我"你的包已经完成了!使用`bundle show [gemname]`来查看捆绑的gem的安装位置",但我的Gem包中仍然缺少sqlite3 (2认同)

小智 5

我遇到了与您提出的问题相同的问题,经过大量的反复试验,我发现了一些简单的步骤可以解决该问题。

首先,添加到您的Gemfile中:

gem 'sqlite3', '1.3.5'
Run Code Online (Sandbox Code Playgroud)

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

bundle install
Run Code Online (Sandbox Code Playgroud)

然后您应该正常进行