Similar question on SO, but dealing with rails 5. This instance: Rails 6.0.3 with VPS in development.
Running
RAILS_ENV=development bundle exec rails assets:precompile
on the server, or cap development deploy
locally to deploy lead to the fact that listen appears to be hidden from vue.
Server:
RAILS_ENV=development bundle exec rails assets:precompile
rails aborted!
LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
local deploying:
01 rake aborted!
01 LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
01 /home/deploy/zappa/shared/bundle/ruby/2.6.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
01 /home/deploy/zappa/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'
...
01 Caused by:
01 LoadError: cannot load such file -- listen
but here's the thing:
group :development do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.4'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
Commenting out the gem from the Gemfile predictably fails; I assume rails wants to know about changes and only act upon those.
Running RAILS_ENV=development bundle install
returns a clue:
Gems in the groups development and test were not installed.
So how does one go about making listen
gem visible?
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; see answer below
the most direct way to overcome the issue is by adding
set :bundle_without, %w{test}.join(':')
to the deploy/development.rb
configuration file as per the capistrano instructions.
The default setting is:
set :bundle_without, %w{development test}.join(':')
which is counter-intuitive for development environment.
The error message is also misleading:
LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile