【问题标题】:Sqlite3 gem not loading, gem installed and specified in projectSqlite3 gem未加载,gem已安装并在项目中指定
【发布时间】:2013-09-05 19:37:06
【问题描述】:

因此,在我寻求让 ruby​​ 开发环境正常工作的过程中,我遇到了一个问题,似乎……让这个 ruby​​ 菜鸟感到困惑。

在执行 rails server 时,它会按预期启动,但是当您将 localhost:3000 输入到标准 Web 浏览器时,它会回复以下内容:

为数据库适配器指定了“sqlite3”,但未加载 gem。将gem 'sqlite3' 添加到您的 Gemfile。

现在这是令人困惑的部分。我已经安装了 sqlite3(64 位版本,因为这是我下载的,并且正在运行 64 位操作系统),已通过 gem 查询验证(这里是 gem 的完整列表)

卸载和重新安装并没有解决手头的问题,但安装起来很顺利。我正在测试的项目的gemfile也是以下

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

如您所见,很早就在 Gemfile 中指定了 sqlite3,但无论出于何种原因,当我尝试加载主页时,它的表现就像它不存在一样。

这台机器的细节如下,前面的宝石部分没有提到:

导轨 4 红宝石 2 视窗 7

以前有人遇到过这种情况吗?

【问题讨论】:

  • 路径中有sqlite dll吗?
  • @bala 在您发送消息时我还没有(假设在安装 gem 时它安装了所有依赖项......显示了假设您得到了什么),所以我从 sqlite.org/download.html 下载了 sqlite3.dll 和把它放在 E:\Programs\Ruby200-x64\lib\ruby\gems\2.0.0\gems\sqlite3-1.3.8-x64-mingw32\lib\sqlite3\2.0 (如果它包括所有子目录)具有相同的结果。
  • 你可以在将 dll 放到 ruby​​\bin 路径后尝试一下吗?
  • @Bala 在 ruby​​/bin 中尝试过,结果相同。

标签: ruby-on-rails ruby windows sqlite


【解决方案1】:

我也遇到了这个问题。进入您的 Gemfile.lock 文件并搜索“sqlite3”条目。你会注意到它是sqlite3 (1.3.8-x86-mingw32). 将其更改为sqlite3 (1.3.8-x64-mingw32),然后运行bundle install 命令,一切都会正常运行。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,这似乎是 Windows 7 特定的环境问题。通过以下更改解决了我的问题

    进入您的 Gemfile.lock 文件并将 sqlite3 (1.3.8-x86-mingw32) 更新为 sqlite3 (1.3.8-x64-mingw32)

    【讨论】:

    • 这是正确的!谢谢!
    【解决方案3】:

    从项目目录运行bundle install。这将更新 Gemfile.lock。您还必须重新启动 Rails 服务器。

    另见config/database.yml,它指定了数据库使用的gem。

    development:
      adapter: sqlite3
      database: db/test.sqlite3
      pool: 5
      timeout: 5000
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 2011-06-28
      • 2016-03-13
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      相关资源
      最近更新 更多