1

I am perplexed by the following issue:

When launching a rails server in production using the following command: bundle exec rails s -e production, I get a 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>'

However, when I launch rails within the development environment, everything works fine. I can't seem to find the issue. Why is this?

The full gemfile:

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'

I would guess there might be something wrong with a path configuration but I do not know where to go from here, can anyone point me in the right direction?

Server environment:

  • Ubuntu 20.04.2 LTS

  • ruby:

    interpreter: "ruby"

    version: "3.0.0p0"

    date: "2020-12-25"

    platform: "x86_64-linux"

    patchlevel: "2020-12-25 revision 95aff21468"

    full_version: "ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]"

Lagastic
  • 137
  • 1
  • 1
  • 9
  • 5
    It seems that in your `app/controllers/extended_responses_controller.rb` file in line 2, you have something like `require "Response"`. However, there is no such file. Maybe there is a file called `response.rb` you want to load though. On macOS and Windows, capitalization of filenames is (usually) not relevant, on Linux it always is though. – Holger Just Jan 20 '22 at 14:58
  • Oh wow, that was indeed the problem, didn't make the link with the response defined in my own application. Kind of confusing error message, thought that the problem was somewhere with bootsnap and a Response there. Thanks a lot! – Lagastic Jan 20 '22 at 15:45
  • 1
    @HolgerJust one way to avoid getting these issues into production is to use a partition (or a drive) with a case sensitive file system for your project files or use a VM with a case sensitive virtual file system. Unfortunately AFAIK OS-X doesn't like it if your startup drive is HFS+ CS and there are several features that break. – max Jan 20 '22 at 16:47
  • 1
    One a side note if you're using Bundler 2.0+ you can get rid of `git_source(:github) { |repo| "https://github.com/#{repo}.git" }` which is a hacky workaround for a volunerability in Bundler 1.x. – max Jan 20 '22 at 16:50

0 Answers0