【发布时间】:2020-03-25 13:19:41
【问题描述】:
在我重新加载我的 localhost:3000 网页之前,它说:
$ rails s
=> Booting Puma
=> Rails 6.0.1 application starting in development
=> Run `rails server --help` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 4.3.0 (ruby 2.6.5-p114), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://[::1]:3000
* Listening on tcp://127.0.0.1:3000
Use Ctrl-C to stop
然后我重新加载后:
2019-11-29 20:18:59 -0800: Rack app error handling request { GET / }
#<LoadError: Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4), already activated sqlite3-1.3.13.20180326210955. Make sure all dependencies are added to Gemfile.>
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/rubygems_integration.rb:406:in `block (2 levels) in replace_gem'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `<top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/connection_specification.rb:170:in `spec'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1054:in `establish_connection'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_handling.rb:51:in `establish_connection'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/railtie.rb:201:in `block (2 levels) in <class:Railtie>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:72:in `class_eval'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:72:in `block in execute_hook'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/base.rb:327:in `<module:ActiveRecord>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/base.rb:27:in `<top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/query_cache.rb:31:in `run'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:28:in `before'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:429:in `block in make_lambda'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:201:in `block (2 levels) in halting'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:607:in `block (2 levels) in default_terminator'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:606:in `catch'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:606:in `block in default_terminator'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:202:in `block in halting'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:514:in `block in invoke_before'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:514:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:514:in `invoke_before'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:134:in `run_callbacks'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:111:in `run!'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:73:in `block in run!'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:70:in `tap'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:70:in `run!'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/actionpack-6.0.1/lib/action_dispatch/middleware/executor.rb:12:in `call'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/actionpack-6.0.1/lib/action_dispatch/middleware/static.rb:126:in `call'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/actionpack-6.0.1/lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webpacker-4.2.0/lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in `call'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.1/lib/rails/engine.rb:526:in `call'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.0/lib/puma/configuration.rb:228:in `call'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.0/lib/puma/server.rb:667:in `handle_request'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.0/lib/puma/server.rb:470:in `process_client'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.0/lib/puma/server.rb:328:in `block in run'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/puma-4.3.0/lib/puma/thread_pool.rb:134:in `block in spawn_thread'
这是我在 SQLite3 的 gemfile 中的内容:
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
我正在运行这些版本:
$ sqlite3 --version
3.30.1
$ rails -v
Rails 6.0.1
$ ruby -v
ruby 2.6.5p114
过去三天我一直在尝试启动 Rails 服务器,这是我得到的最远的一次。我猜我的 gemfile 中的内容与它正在检查的其他内容之间存在差异。我正在尝试按照 YouTube 教程制作我的第一个应用程序。
【问题讨论】:
-
你为什么使用 Github 的 sqlite 分支?
-
只有一个有效的。这是我尝试过的其他方法: gem 'sqlite3' gem 'sqlite3', 'github.com/larskanis/sqlite3-ruby", branch: "add-gemspec" gem "sqlite3", "~> 1.3 .6"
-
尝试运行最新最好的版本可能不是一个好主意。我会尝试卸载这个 6.0.1 版本,并从 v5 分支安装最后一个版本,即 5.2.4 (
gem uninstall rails; gem install rails -v 5.2.4)。然后再试一次。 -
如果你在使用 sqlite 时碰壁了——不要使用它。 Rails 默认是因为它(通常)是一个易于设置的数据库,用于快速原型设计和学习。这不是您要实际部署的内容,也不是您应该开发/测试真实应用程序的内容。我建议你改用 postgres。
-
@Casper 我在尝试降级我的 Rails 版本时遇到了麻烦。是否有另一种降级方法,因为这些命令只会导致我出错。谢谢
标签: ruby-on-rails ruby sqlite sqlite3-ruby