[英]LoadError: Could not load the 'listen' gem (Rails 6)
Similar question on SO, but dealing with rails 5. This instance: Rails 6.0.3 with VPS in development.关于 SO 的类似问题,但处理的是 rails 5。这个实例: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.在服务器上,或
cap development deploy
locally to deploy 导致 listen 似乎对 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;从 Gemfile 中注释掉 gem 预计会失败; I assume rails wants to know about changes and only act upon those.
我假设 Rails 想要了解变化并且只对这些变化采取行动。
Running RAILS_ENV=development bundle install
returns a clue:运行
RAILS_ENV=development bundle install
返回一条线索:
Gems in the groups development and test were not installed.
So how does one go about making listen
gem visible?那么一个 go 如何让
listen
gem 可见呢?
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.将 gem 调用移出
development
块并移入全局块允许RAILS_ENV=development bundle install
在远程服务器上运行。 Now the listen gem is installed and the deployment can proceed with compilation.现在安装了 listen gem,部署可以继续进行编译。 this is a hack, as listen is meant only for development mode;
这是一个 hack,因为 listen 仅适用于开发模式; 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 .根据capistrano 说明添加到
deploy/development.rb
配置文件。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.