2011-12-08 94 views
1

我试图通过我的导轨控制台在我新创建的应用程序中打开,但我无法连接到数据库。它看起来像有可能与sqlite3-1.3.3问题VS 1.3.4导轨连接到数据库

$ rails c 
/Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `establish_connection': Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (can't activate sqlite3 (~> 1.3.4, runtime), already activated sqlite3-1.3.3. Make sure all dependencies are added to Gemfile.) (RuntimeError) 

安装

$sudo gem install 
ERROR: could not find gem activerecord-sqlite3-adapter locally or in a repository 

我已经安装了什么宝石

$gem list 

*** LOCAL GEMS *** 
... 
sqlite3 (1.3.3) 
sqlite3-ruby (1.3.3, 1.3.2, 1.2.5) 

我使用的是轨道3.1.1

编辑:

这里是我的Gemfile 源 'http://rubygems.org' 宝石 '轨道', '3.1.1'

# Bundle edge Rails instead: 
# gem 'rails',  :git => 'git://github.com/rails/rails.git' 

gem 'sqlite3' 
gem 'json' 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.1.4' 
    gem 'coffee-rails', '~> 3.1.1' 
    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

运行捆绑安装产生这种 $ sudo的使用捆绑耙(0.9安装 。 2.2) ...使用sqlite3(1.3.3) 您的包已完成!使用bundle show [gemname]查看安装了捆绑宝石的位置。

$ bundle show sqlite3 
/Library/Ruby/Gems/1.8/gems/sqlite3-1.3.3 
+0

什么是你'Gemfile'包含(不'Gemfile.lock')? – jefflunt

+0

'bundle exec rails c'输出是什么? –

回答

1

您正在使用Rails 3.1,它使用bundler来管理宝石。

  1. 添加gem 'sqlite3'到你的Gemfile
  2. 运行bundle以命令行形式

这将安装宝石您的应用需求。您应该能够启动控制台。

+0

没有工作:/我将它添加到我的gemfile并运行包。我仍然得到同样的错误。 – will

+0

如果您还将'gem'sqlite3-rails''添加到您的包中,该怎么办? –

0

我以前见过类似的情况,因为缺少/不好的共享库。 Gems安装ruby代码,本地绑定到库,但它们本身不安装外部库。

例如,Ubuntu上的sqlite的依赖关系是libsqlite3-dev。

$ sudo apt-get install libsqlite3-dev 

对于OSX:

Install sqlite3 on mac osx?