1

我对以下问题感到困惑:

使用以下命令在生产中启动 rails 服务器时: bundle exec rails s -e production,我得到一个 LoadError:

=> Booting Puma
=> Rails 6.1.4.4 application starting in production 
=> Run `bin/rails server --help` for more startup options
Exiting
/usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:46:in `require': cannot load such file -- Response (LoadError)
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:46:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:35:in `require'
    from /home/test/pensiontest-backend/data-api/app/controllers/extended_responses_controller.rb:2:in `<main>'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:27:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader/helpers.rb:95:in `const_get'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader/helpers.rb:95:in `cget'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader.rb:231:in `block (2 levels) in eager_load'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader/helpers.rb:26:in `block in ls'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader/helpers.rb:18:in `each_child'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader/helpers.rb:18:in `ls'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader.rb:226:in `block in eager_load'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader.rb:211:in `synchronize'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader.rb:211:in `eager_load'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader.rb:311:in `each'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/loader.rb:311:in `eager_load_all'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/application/finisher.rb:133:in `block in <module:Finisher>'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `instance_exec'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `run'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `call'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
    from /usr/share/rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:60:in `run_initializers'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/application.rb:391:in `initialize!'
    from /home/test/pensiontest-backend/data-api/config/environment.rb:5:in `<main>'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:35:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `block in require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:299:in `load_dependency'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:62:in `require_relative'
    from config.ru:3:in `block in <main>'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:312:in `block in start'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:379:in `handle_profiling'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:311:in `start'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/commands/server/server_command.rb:39:in `start'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/commands/server/server_command.rb:144:in `block in perform'
    from <internal:kernel>:90:in `tap'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/commands/server/server_command.rb:135:in `perform'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/command/base.rb:69:in `perform'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/command.rb:48:in `invoke'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/railties-6.1.4.4/lib/rails/commands.rb:18:in `<main>'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/bootsnap-1.10.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:28:in `require'
    from /home/test/pensiontest-backend/data-api/bin/rails:5:in `<top (required)>'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `load'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `call'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/spring-4.0.0/lib/spring/client/command.rb:7:in `call'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/spring-4.0.0/lib/spring/client.rb:30:in `run'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/spring-4.0.0/bin/spring:49:in `<top (required)>'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `load'
    from /usr/share/rvm/gems/ruby-3.0.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
    from /home/test/pensiontest-backend/data-api/bin/spring:10:in `require'
    from /home/test/pensiontest-backend/data-api/bin/spring:10:in `block in <top (required)>'
    from <internal:kernel>:90:in `tap'
    from /home/test/pensiontest-backend/data-api/bin/spring:7:in `<top (required)>'
    from bin/rails:2:in `load'
    from bin/rails:2:in `<main>'

但是,当我在开发环境中启动 rails 时,一切正常。我似乎找不到问题。为什么是这样?

完整的宝石文件:

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

ruby '3.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.3', '>= 6.1.3.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.1'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', 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.3'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

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

# ALLOW CORS ONLY FOR DEV
gem 'rack-cors'

gem 'unicorn'

gem 'responders'

gem 'postmark-rails'

# gem 'bcrypt'

我猜路径配置可能有问题,但我不知道从哪里开始,谁能指出我正确的方向?

服务器环境:

  • Ubuntu 20.04.2 LTS

  • 红宝石:

    翻译:“红宝石”

    版本:“3.0.0p0”

    日期:“2020-12-25”

    平台:“x86_64-linux”

    补丁级别:“2020-12-25 修订版 95aff21468”

    full_version:“ruby 3.0.0p0(2020-12-25 修订版 95aff21468)[x86_64-linux]”

4

0 回答 0