Could not load the 'postgres' Active Record adapter
LongLonghaoran opened this issue · 4 comments
I meet this error when my database.yml has been configured to use postgresql.
And i found some code here
def default_sequel_adapter_options(world)
db_config = ::ActiveRecord::Base.configurations.to_h[::Rails.env]
db_config['adapter'] = db_config['adapter'].gsub(/_?makara_?/, '')
# what is this mean?
db_config['adapter'] = 'postgres' if db_config['adapter'] == 'postgresql'
db_config['max_connections'] = calculate_db_pool_size(world) if increase_db_pool_size?
if db_config['adapter'] == 'sqlite3'
db_config['adapter'] = 'sqlite'
database = db_config['database']
unless database == ':memory:'
# We need to create separate database for sqlite
# to avoid lock conflicts on the database
db_config['database'] = "#{File.dirname(database)}/dynflow-#{File.basename(database)}"
end
end
db_config
end
Could you paste the exact error you're getting, ideally with a stack trace?
: sidekiq -r ./extras/dynflow-sidekiq.rb
Your Gemfile lists the gem puma (~> 5.1) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
2022-01-26T01:01:19.808Z 74384 TID-1j7c INFO: GitLab reliable fetch activated!
2022-01-26T01:01:19.824Z 74384 TID-1inc INFO: Booting Sidekiq 5.2.9 with redis options {:id=>"Sidekiq-server-PID-74384", :url=>nil}
/Users/eddy/.rvm/gems/ruby-2.7.3/gems/pry-byebug-3.8.0/lib/pry-byebug/control_d_handler.rb:5: warning: control_d_handler's arity of 2 parameters was deprecated (eval_string, pry_instance). Now it gets passed just 1 parameter (pry_instance)
/Users/eddy/workspace/foreman-2.5.2/lib/foreman.rb:8: warning: already initialized constant Foreman::UUID_REGEXP
/Users/eddy/workspace/foreman-2.5.2/lib/foreman.rb:8: warning: previous definition of UUID_REGEXP was here
2022-01-26T09:01:25 [I|app|] Rails cache backend: File
The Apipie cache is turned off. Enable it and run apipie:cache rake task to speed up API calls.
...
2022-01-26T09:01:42 [D|sql|] ↳ app/services/foreman_seeder.rb:71:in `old_hash'
2022-01-26T09:01:42 [I|app|] No new seed file updates found. Skipping
2022-01-26T09:01:44 [I|dyn|] start terminating throttle_limiter...
2022-01-26T09:01:44 [I|dyn|] start terminating client dispatcher...
2022-01-26T09:01:44 [I|dyn|] stop listening for new events...
2022-01-26T09:01:44 [I|dyn|] start terminating clock...
Traceback (most recent call last):
25: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in `<main>'
24: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in `eval'
23: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in `<main>'
22: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in `load'
21: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/bin/sidekiq:12:in `<top (required)>'
20: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:46:in `run'
19: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in `boot_system'
18: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in `require'
17: from /Users/eddy/workspace/foreman-2.5.2/extras/dynflow-sidekiq.rb:29:in `<top (required)>'
16: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in `initialize!'
15: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in `tap'
14: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:41:in `block in initialize!'
13: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails/configuration.rb:132:in `increase_db_pool_size'
12: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-import-1.2.0/lib/activerecord-import/import.rb:250:in `establish_connection'
11: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_handling.rb:51:in `establish_connection'
10: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1052:in `establish_connection'
9: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/connection_specification.rb:169:in `spec'
8: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require'
7: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
6: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `block in require'
5: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
4: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
3: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
2: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
1: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- active_record/connection_adapters/postgres_adapter (LoadError)
25: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in `<main>'
24: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in `eval'
23: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in `<main>'
22: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in `load'
21: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/bin/sidekiq:12:in `<top (required)>'
20: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:46:in `run'
19: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in `boot_system'
18: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in `require'
17: from /Users/eddy/workspace/foreman-2.5.2/extras/dynflow-sidekiq.rb:29:in `<top (required)>'
16: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in `initialize!'
15: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in `tap'
14: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:41:in `block in initialize!'
13: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails/configuration.rb:132:in `increase_db_pool_size'
12: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-import-1.2.0/lib/activerecord-import/import.rb:250:in `establish_connection'
11: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_handling.rb:51:in `establish_connection'
10: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1052:in `establish_connection'
9: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/connection_specification.rb:169:in `spec'
8: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require'
7: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
6: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `block in require'
5: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
4: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
3: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
2: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
1: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': Could not load the 'postgres' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile. (LoadError)
Edit: Styling
`
: sidekiq -r ./extras/dynflow-sidekiq.rb
Your Gemfile lists the gem puma (~> 5.1) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
2022-01-26T01:01:19.808Z 74384 TID-1j7c INFO: GitLab reliable fetch activated!
2022-01-26T01:01:19.824Z 74384 TID-1inc INFO: Booting Sidekiq 5.2.9 with redis options {:id=>"Sidekiq-server-PID-74384", :url=>nil}
/Users/eddy/.rvm/gems/ruby-2.7.3/gems/pry-byebug-3.8.0/lib/pry-byebug/control_d_handler.rb:5: warning: control_d_handler's arity of 2 parameters was deprecated (eval_string, pry_instance). Now it gets passed just 1 parameter (pry_instance)
/Users/eddy/workspace/foreman-2.5.2/lib/foreman.rb:8: warning: already initialized constant Foreman::UUID_REGEXP
/Users/eddy/workspace/foreman-2.5.2/lib/foreman.rb:8: warning: previous definition of UUID_REGEXP was here
2022-01-26T09:01:25 [I|app|] Rails cache backend: File
The Apipie cache is turned off. Enable it and run apipie:cache rake task to speed up API calls.
...
2022-01-26T09:01:42 [D|sql|] ↳ app/services/foreman_seeder.rb:71:in old_hash' 2022-01-26T09:01:42 [I|app|] No new seed file updates found. Skipping 2022-01-26T09:01:44 [I|dyn|] start terminating throttle_limiter... 2022-01-26T09:01:44 [I|dyn|] start terminating client dispatcher... 2022-01-26T09:01:44 [I|dyn|] stop listening for new events... 2022-01-26T09:01:44 [I|dyn|] start terminating clock... Traceback (most recent call last): 25: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in
24: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in
eval' 23: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in
'22: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in
load' 21: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/bin/sidekiq:12:in
<top (required)>'20: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:46:in
run' 19: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in
boot_system'18: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in
require' 17: from /Users/eddy/workspace/foreman-2.5.2/extras/dynflow-sidekiq.rb:29:in
<top (required)>'16: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in
initialize!' 15: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in
tap'14: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:41:in
block in initialize!' 13: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails/configuration.rb:132:in
increase_db_pool_size'12: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-import-1.2.0/lib/activerecord-import/import.rb:250:in
establish_connection' 11: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_handling.rb:51:in
establish_connection'10: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1052:in
establish_connection' 9: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/connection_specification.rb:169:in
spec'8: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in
require' 7: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in
load_dependency'6: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in
block in require' 5: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/polyglot-0.3.5/lib/polyglot.rb:65:in
require'4: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in
require' 3: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in
require_with_bootsnap_lfi'2: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in
register' 1: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in
block in require_with_bootsnap_lfi'/Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in
require': cannot load such file -- active_record/connection_adapters/postgres_adapter (LoadError) 25: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in
'24: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/ruby_executable_hooks:22:in
eval' 23: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in
'22: from /Users/eddy/.rvm/gems/ruby-2.7.3/bin/sidekiq:23:in
load' 21: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/bin/sidekiq:12:in
<top (required)>'20: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:46:in
run' 19: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in
boot_system'18: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:292:in
require' 17: from /Users/eddy/workspace/foreman-2.5.2/extras/dynflow-sidekiq.rb:29:in
<top (required)>'16: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in
initialize!' 15: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:38:in
tap'14: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails.rb:41:in
block in initialize!' 13: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/dynflow-1.6.1/lib/dynflow/rails/configuration.rb:132:in
increase_db_pool_size'12: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-import-1.2.0/lib/activerecord-import/import.rb:250:in
establish_connection' 11: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_handling.rb:51:in
establish_connection'10: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1052:in
establish_connection' 9: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/connection_specification.rb:169:in
spec'8: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in
require' 7: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in
load_dependency'6: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in
block in require' 5: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/polyglot-0.3.5/lib/polyglot.rb:65:in
require'4: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in
require' 3: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in
require_with_bootsnap_lfi'2: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in
register' 1: from /Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in
block in require_with_bootsnap_lfi'/Users/eddy/.rvm/gems/ruby-2.7.3/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in
require': Could not load the 'postgres' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile. (LoadError)