简体   繁体   English

LoadError: 无法加载 'listen' gem (Rails 6)

[英]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.

相关问题 加载错误:无法加载“监听”gem(Rails 5) - LoadError: Could not load the 'listen' gem (Rails 5) 找不到RubyGem rails(> = 0)(Gem :: LoadError) - Could not find RubyGem rails (>= 0) (Gem::LoadError) 在 [] (Gem::LoadError) 中找不到导轨 (>= 0) - Could not find rails (>= 0) amongst [] (Gem::LoadError) Rails:LoadError-无法加载此类文件(需要gem) - Rails: LoadError - Cannot load such file (requiring a gem) Rails服务器错误:“找不到RubyGem rails(> = 0)(Gem :: LoadError)” - Rails Server Error: “Could not find RubyGem rails (>=0) (Gem:: LoadError)” Ruby on rails: - 找不到RubyGem rails(> = 0)(Gem :: LoadError) - Ruby on rails :- Could not find RubyGem rails (>= 0) (Gem::LoadError) 使用rails 2.3.18在[](Gem :: LoadError)中找不到bundler(> = 0) - Could not find bundler (>= 0) amongst [] (Gem::LoadError) with rails 2.3.18 rails 2.3.2项目:找不到RubyGem uuid(> = 0)(Gem :: LoadError) - rails 2.3.2 project: Could not find RubyGem uuid (>= 0) (Gem::LoadError) rails gem 'countries' - LoadError: 无法加载此类文件 - iso3166 - rails gem 'countries' - LoadError: cannot load such file -- iso3166 Ruby:`gem_original_require':没有这样的文件要加载 - rails(LoadError) - Ruby: `gem_original_require': no such file to load — rails (LoadError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM