Я работаю над чьим-то сайтом, пытаюсь запустить Rails. Файлы, отправленные мне, включали gemfile, в котором была установлена gem 'pg', '0.21.0'. However, when I run
bundler, я получаю
Bundler could not find compatible versions for gem "ruby ":
In Gemfile:
ruby (~> 2.6.6.0)
pg (= 0.21.0) was resolved to 0.21.0, which depends on
ruby (>= 2.0.0)
pg (= 0.21.0) was resolved to 0.21.0, which depends on
ruby (< 2.5, >= 2.0) x64-mingw32
Кроме того, если я пытаюсь запустить rails server
или rails -v
после такой неудачной попытки, я получаю
Could not find gem 'pg (= 0.21.0) x64-mingw32' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
Я использую Ruby 2.6.6p146 и Rails 4.2.10, хотя я могу легко изменить версию Rails, и, похоже, это не влияет на это. Я набираю Windows 10, если поможет.
Похоже, мне нужно использовать более свежую версию pg. Когда я пробую это (самая ранняя совместимая версия - 1.1.4), bundle install
работает хорошо. Но затем rails server
выдает
Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
Похоже, я застрял между этими двумя ошибками, где на основе моей версии pg в gemfile я обязательно получу одну из них, и ни один из них не позволяет мне запускать rails server
.
Есть ли способ обойти это, желательно решение, которое позволит мне сохранить 0.21.0 в гем-файле? Я также рад решению, которое позволяет обойти вторую ошибку.
Вот полная трассировка стека для второй ошибки:
C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/etc.so: warning: already initialized constant Struct::Passwd
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/core_ext/object/duplicable.rb:111: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
C:/Ruby26-x64/lib/ruby/2.6.0/forwardable.rb:116: warning: already initialized constant Forwardable::VERSION
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/forwardable-1.3.1/lib/forwardable/version.rb:3: warning: previous definition of VERSION was here
C:/Ruby26-x64/lib/ruby/2.6.0/forwardable.rb:117: warning: already initialized constant Forwardable::FORWARDABLE_VERSION
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/forwardable-1.3.1/lib/forwardable/version.rb:4: warning: previous definition of FORWARDABLE_VERSION was here
=> Booting WEBrick
=> Rails 4.2.10 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
Traceback (most recent call last):
56: from bin/rails:4:in `<main>'
55: from bin/rails:4:in `require'
54: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
53: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
52: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `server'
51: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `tap'
50: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:80:in `block in server'
49: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/server.rb:78:in `start'
48: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/server.rb:139:in `log_to_stdout'
47: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/server.rb:337:in `wrapped_app'
46: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/server.rb:61:in `app'
45: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/server.rb:209:in `app'
44: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/server.rb:300:in `build_app_and_options_from_config'
43: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:40:in `parse_file'
42: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:49:in `new_from_string'
41: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:49:in `eval'
40: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config.ru:in `<main>'
39: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config.ru:in `new'
38: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:55:in `initialize'
37: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:55:in `instance_eval'
36: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config.ru:3:in `block in <main>'
35: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
34: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
33: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
32: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
31: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config/environment.rb:5:in `<top (required)>'
30: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/railtie.rb:194:in `method_missing'
29: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/railtie.rb:194:in `public_send'
28: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/application.rb:352:in `initialize!'
27: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:54:in `run_initializers'
26: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
25: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
24: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
23: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `call'
22: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `each'
21: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
20: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
19: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
18: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
17: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
16: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `run'
15: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `instance_exec'
14: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/railtie.rb:118:in `block in <class:Railtie>'
13: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
12: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:27:in `each'
11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/railtie.rb:122:in `block (2 levels) in <class:Railtie>'
7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/connection_handling.rb:50:in `establish_connection'
6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/postgresql_adapter.rb:16:in `<top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem': can't activate pg (~> 0.15), already activated pg-1.1.4-x64-mingw32. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
51: from bin/rails:4:in `<main>'
50: from bin/rails:4:in `require'
49: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
48: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
47: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `server'
46: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `tap'
45: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:80:in `block in server'
44: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/server.rb:78:in `start'
43: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/server.rb:139:in `log_to_stdout'
42: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/server.rb:337:in `wrapped_app'
41: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/commands/server.rb:61:in `app'
40: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/server.rb:209:in `app'
39: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/server.rb:300:in `build_app_and_options_from_config'
38: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:40:in `parse_file'
37: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:49:in `new_from_string'
36: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:49:in `eval'
35: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config.ru:in `<main>'
34: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config.ru:in `new'
33: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:55:in `initialize'
32: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-1.6.13/lib/rack/builder.rb:55:in `instance_eval'
31: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config.ru:3:in `block in <main>'
30: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
29: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
28: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `block in require'
27: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in `require'
26: from C:/Users/iijof/Desktop/Jobs/You3dit/y3dialpha/config/environment.rb:5:in `<top (required)>'
25: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/railtie.rb:194:in `method_missing'
24: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/railtie.rb:194:in `public_send'
23: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/application.rb:352:in `initialize!'
22: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:54:in `run_initializers'
21: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
20: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
19: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
18: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `call'
17: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `each'
16: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
15: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
14: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
13: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
12: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `run'
10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-4.2.10/lib/rails/initializable.rb:30:in `instance_exec'
9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/railtie.rb:118:in `block in <class:Railtie>'
8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:27:in `each'
6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/railtie.rb:122:in `block (2 levels) in <class:Railtie>'
2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/connection_handling.rb:50:in `establish_connection'
1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)