微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rails 错误:replace_gem 中的块2 级:加载“sqlite3”活动记录适配器时出错

如何解决Rails 错误:replace_gem 中的块2 级:加载“sqlite3”活动记录适配器时出错

我见过其他类似的问题(例如 this one),但略有不同。

我使用命令 rails new backend -d=postgresql -T --api 创建了一个全新的 Rails API 应用程序。我已将数据库全部设置并连接正常。现在我正在尝试安装 graphql gem。它在我的 Gemfile 中,我已经运行了 bundle install,下一步是根据文档运行命令 bundle exec rails generate graphql:install。但是,当我运行它时,出现此错误

/Users/jimmiejackson/.rvm/gems/ruby-2.5.5/gems/bundler-2.2.11/lib/bundler/rubygems_integration.rb:334:in `block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile. (LoadError)
    from /Users/jimmiejackson/.rvm/gems/ruby-2.5.5/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `<top (required)>'
    from ...
    from ...

我在 Github 问题、Google 或 Stack 中找不到任何答案。我不知道为什么当我从新安装 postgresql 时会收到 sqlite 错误。我上次开发 Rails 应用已经有一段时间了,可能是什么问题?

Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.5'

gem 'rails','~> 6.0.3','>= 6.0.3.5'
gem 'pg','>= 0.18','< 2.0'
gem 'puma','~> 4.1'
gem 'bcrypt','~> 3.1.7'
gem 'graphql','1.9.17'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap','>= 1.4.2',require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS),making cross-origin AJAX possible
gem 'rack-cors'

group :development,:test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug',platforms: [:mri,:mingw,:x64_mingw]
end

group :development do
  gem 'listen','~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen','~> 2.0.0'
  gem 'graphiql-rails','1.7.0'
end

# Windows does not include zoneinfo files,so bundle the tzinfo-data gem
gem 'tzinfo-data',platforms: [:mingw,:mswin,:x64_mingw,:jruby]

database.yml:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: movie_show_tracker_development

test:
  <<: *default
  database: movie_show_tracker_test

解决方法

好吧,我终于搞定了。我最终不得不重新从头开始这个项目,并使用 Ruby v.2.6.3/Rails v.6.0.3.5 来让 graphql gem 正常工作。甚至不确定这些是否是罪魁祸首,但它现在似乎起作用了!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?