guard / listen

The Listen gem listens to file modifications and notifies you about the changes.
https://rubygems.org/gems/listen
MIT License
1.92k stars 245 forks source link

listen should not be hidden #530

Closed dvodvo closed 2 years ago

dvodvo commented 3 years ago

If deploying in development mode, the whole process will break down in asset precompilation.

Details of how I got there, and over the hump: https://stackoverflow.com/questions/65707369/loaderror-could-not-load-the-listen-gem-rails-6

What is apparent is that the gem should be in the global block if deploying in development mode. But that is not obvious, for the dependency is lower down.

It would be best if this were part of the error message. The present one: LoadError: Could not load the 'listen' gem. Addgem 'listen'to the development group of your Gemfile is misleading.

ColinDKelley commented 3 years ago

@dvodvo It looks like this is regarding Rails 6's use of listen and specifically, how it generates the Gemfile to have listen only in the :development block. Do I have that right?

If so, is there anything we can do in the listen gem to help? Or does the fix need to go into Rails?

dvodvo commented 3 years ago

As far as I can tell it does not appear below 6. There is an added wrinkle which I discovered, which may involve capistrano and the bundler command. Issuing bundle install --with development allows listen to process and deployment to complete.

I had never had to configure capistrano for the bundle command (and have not done so yet, as I am uncertain which is the best way to proceed). Thus the best target for adjusting things is not obvious to me.

dvodvo commented 3 years ago

OK. I ran a whole process, just to be sure of what is going on.

      01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
      01 rake aborted!
      01 LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile

is definitely a misleading error notification.

If one then runs bundle install --with development server side, the error shifts

      03 $HOME/.rbenv/bin/rbenv exec bundle config --local without development:test
      03 You are replacing the current local value of without, which is currently "test"
      03 Setting `without` to [:development, :test] failed:

the most direct way to overcome the issue is by adding set :bundle_without, %w{test}.join(':') as per the capistrano instructions in lieu of the default settings.

So -to [ahem] not answer your question- between listen, bundler, capistrano and rails, I do not know which party contributes to the initial misleading error notice.

ColinDKelley commented 3 years ago

I don't think the listen gem is involved in those errors.

The confusing error messages appear to be from Bundler + Rails.

This same issue was discussed 4 years ago for Rails 5: https://stackoverflow.com/questions/38663706/loaderror-could-not-load-the-listen-gem-rails-5

The top answer then pointed to this config line

  # Use an evented file watcher to asynchronously detect changes in source code,
  # routes, locales, etc. This feature depends on the listen gem.
  config.file_watcher = ActiveSupport::EventedFileUpdateChecker

which others point out could be made conditional:

  if defined?(Listen)
    config.file_watcher = ActiveSupport::EventedFileUpdateChecker
  end

Can you try that?

dvodvo commented 3 years ago

Yes, config.file_watcher = ActiveSupport::EventedFileUpdateChecker is present in rails 6 as well. no, making that statement conditional does not allow to overcome the $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompileaction.

Only the above suggestion: set :bundle_without, %w{test}.join(':') makes the processes run as expected.

In any instance, could that conditional truly be consequential? the development block not being bundled in development may also affect other gems.

So it seems the real issue is with the bundler defaults. Why would deploying to a development stage exclude that block of gems? That logic may be an issue of configuration choices. But the error messaging are off-base. Not sure if rails, capistrano or bundler should be appraised of this case.

ColinDKelley commented 3 years ago

So it seems the real issue is with the bundler defaults. Why would deploying to a development stage exclude that block of gems?

That does seem wrong, if those defaults apply in the development environment. Rails is counting on the development block of gems to not be excluded when RAILS_ENV=development.

Can you think of a way that Rails could detect this mismatch and display a warning message like:

Warning: RAILS_ENV is set to 'development' but Bundler was run with `--without 'development'`.

And also, do you know what code produced the misleading error message? I did a quick search for it in rails and in bundler and rubygems and but didn't find it. Can you run rake --trace and get a traceback of where it's coming from?

LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
ColinDKelley commented 3 years ago

@dvodvo Any thoughts on my questions above?

dvodvo commented 3 years ago

Sorry, had not seen your penultimate message. I am a bit at a loss as to how to run a trace, as this event is fired by capistrano deployment:

set :bundle_without, %w{test}.join(':') 

Given capistrano, bundler and rails are involved, I am not certain how/when/where to invoke a trace. Hopefully bundle exec rake assets:precompile --trace gives us the proper clues

bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/evented_file_update_checker.rb:63:in `block in initialize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/kernel/reporting.rb:15:in `block in silence_warnings'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/kernel/reporting.rb:28:in `with_warnings'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/kernel/reporting.rb:15:in `silence_warnings'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/evented_file_update_checker.rb:62:in `initialize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/i18n_railtie.rb:64:in `new'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/i18n_railtie.rb:64:in `initialize_i18n'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/i18n_railtie.rb:22:in `block in <class:Railtie>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:51:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application/finisher.rb:129:in `block in <module:Finisher>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `instance_exec'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `run'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `each'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `call'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:60:in `run_initializers'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application.rb:363:in `initialize!'
/home/uelcom/fidelity/releases/20210207152809/config/environment.rb:5:in `<main>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application.rb:339:in `require_environment!'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/bin/rake:23:in `load'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/bin/rake:23:in `<top (required)>'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/home/uelcom/.rbenv/versions/2.6.1/bin/bundle:23:in `load'
/home/uelcom/.rbenv/versions/2.6.1/bin/bundle:23:in `<main>'

Caused by:
LoadError: cannot load such file -- listen
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/evented_file_update_checker.rb:63:in `block in initialize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/kernel/reporting.rb:15:in `block in silence_warnings'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/kernel/reporting.rb:28:in `with_warnings'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/kernel/reporting.rb:15:in `silence_warnings'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/evented_file_update_checker.rb:62:in `initialize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/i18n_railtie.rb:64:in `new'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/i18n_railtie.rb:64:in `initialize_i18n'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/i18n_railtie.rb:22:in `block in <class:Railtie>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:51:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application/finisher.rb:129:in `block in <module:Finisher>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `instance_exec'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `run'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `each'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `call'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:60:in `run_initializers'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application.rb:363:in `initialize!'
/home/uelcom/fidelity/releases/20210207152809/config/environment.rb:5:in `<main>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application.rb:339:in `require_environment!'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/railties-6.0.3.4/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/bin/rake:23:in `load'
/home/uelcom/fidelity/shared/bundle/ruby/2.6.0/bin/rake:23:in `<top (required)>'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/home/uelcom/.rbenv/versions/2.6.1/bin/bundle:23:in `load'
/home/uelcom/.rbenv/versions/2.6.1/bin/bundle:23:in `<main>'
Tasks: TOP => environment
ColinDKelley commented 2 years ago

@dvodvo That backtrace does show that the dependency on Listen is coming from here: https://github.com/rails/rails/blob/main/activesupport/lib/active_support/evented_file_update_checker.rb

I presume that the fact that it's missing means that the bundle install was run with --deployment or --without=development.

Does that seem true?

dvodvo commented 2 years ago

This was run via a cap development deploy capistrano command.

Just ran a process. For it to succeed, I edited the config/deploy/development.rb file with set :bundle_without, %w{test}.join(':') and the gemfile has the block

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.2'
end

The relevant lines in a deploy log do not allude to such an option:

00:28 bundler:config
      01 $HOME/.rbenv/bin/rbenv exec bundle config --local deployment true
      02 $HOME/.rbenv/bin/rbenv exec bundle config --local path /home/jerdvo/fidelity/shared/bundle
      03 $HOME/.rbenv/bin/rbenv exec bundle config --local without test
00:31 bundler:install
      The Gemfile's dependencies are satisfied, skipping installation
00:31 deploy:assets:precompile
      01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile

but I could be wrong.

Does this shed additional light?

ColinDKelley commented 2 years ago

@dvodvo Can you check your bundle config? I see docs recommending a configuration like

bundle config set without 'development:test

which would then have exactly the behavior you're experiencing--the development and test groups would be omitted from bundle install and bundle exec.

The same thing can be accomplished by environment variable:

export BUNDLE_WITHOUT=development:test

so you should check that too.

But looking in StackOverflow, I see that you already worked around the issue in a reasonable way IMO:

Moving the gem call out of the development block and into the global block allows RAILS_ENV=development bundle install to run on the remote server. Now the listen gem is installed and the deployment can proceed with compilation. this is a hack, as listen is meant only for development mode

Sure, but software is full of hacks. Nothing new there. ;)

To summarize:

  1. Rails generates a Gemfile with listen in the :development group.
  2. capistrano recommends and defaults to without development:test in production config.
  3. Rails asset compilation can wind up running config.file_watcher = ActiveSupport::EventedFileUpdateChecker which depends on listen. This will blow up if you followed recommendation (2) and run asset compilation in production.
  4. The error message bundler displays in (3) is confusing.

Your choices to work around this are

  1. Move listen out of the development group.
  2. Don't configure capistrato in production to use without development:test. Just without test would work here.
  3. Don't run asset compilation in production mode.
  4. Edit the generated rails code to only set config.file_watcher when Listen is defined.

If you'd like a permanent improvement, you can lobby with the Rails team to make (1) permanent. Or to recommend (2) and/or (3). Or make (4) permanent. And/or you can lobby the Bundler team for a better error message when (3) happens.

None of these involves Listen, however. So unless I'm missing something, I'd like to close out this issue.

dvodvo commented 2 years ago

Yes, I would close the issue. Having circled the wagons, I conclude the bundler error messaging is the main misleading point.