3

Every time I try to run bundle exec rails console, I get the cannot load such file -- listen (LoadError) on production, however, the rails server(puma) is running and APIs are working. The code is deployed on ElasticBeanstalk and migration files have run successfully and tables created on RDS. The system config is:

Ruby 2.7 running on 64bit Amazon Linux 2
rails version: 6.1

I have no clue why is this trying to load the listener on prod. I do not want to add listener gem to my prod env. Here is my Gemfile

group :development do
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

Adding full trace below:

[ec2-user@ip-172-... current]$ bundle exec rails c
Traceback (most recent call last):
    60: from bin/rails:9:in `<main>'
    59: from bin/rails:9:in `require'
    58: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/commands.rb:18:in `<top (required)>'
    57: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/command.rb:48:in `invoke'
    56: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/command/base.rb:69:in `perform'
    55: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
    54: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
    53: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
    52: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/commands/console/console_command.rb:101:in `perform'
    51: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
    50: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/command/actions.rb:28:in `require_environment!'
    49: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:367:in `require_environment!'
    48: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
    47: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
    46: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
    45: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
    44: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
    43: from /var/app/current/config/environment.rb:5:in `<top (required)>'
    42: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in `initialize!'
    41: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in `run_initializers'
    40: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
    39: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
    38: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
    37: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:347:in `call'
    36: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:347:in `each'
    35: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
    34: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
    33: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:415:in `call'
    32: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `tsort_each_child'
    31: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `each'
    30: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    29: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
    28: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    27: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    26: from /opt/rubies/ruby-2.7.4/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
    25: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
    24: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `run'
    23: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `instance_exec'
    22: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:570:in `block in <class:Engine>'
    21: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:570:in `each'
    20: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:571:in `block (2 levels) in <class:Engine>'
    19: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
    18: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
    17: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
    16: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
    15: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
    14: from /var/app/current/config/environments/development.rb:1:in `<top (required)>'
    13: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:234:in `configure'
    12: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:234:in `instance_eval'
    11: from /var/app/current/config/environments/development.rb:57:in `block in <top (required)>'
    10: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
     9: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
     8: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
     7: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
     6: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
     5: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/evented_file_update_checker.rb:6:in `<top (required)>'
     4: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
     3: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
     2: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
     1: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/var/app/current/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require': cannot load such file -- listen (LoadError)

If I try to run RAILS_ENV=production bundle exec rails c I get

could not connect to server: No such file or directory (PG::ConnectionBad)
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Please note I'm using rds and migrations are successful.

Imran Ahmad
  • 2,798
  • 3
  • 28
  • 49

0 Answers0