我有一个API模式Rails 5应用程序,它不允许我运行rake routes
或rails s
。我得到的错误是:
$ rake routes
rake aborted!
LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
.../config/environment.rb:5:in `<top (required)>'
LoadError: cannot load such file -- listen
.../config/environment.rb:5:in `<top (required)>'
Tasks: TOP => routes => environment
(See full trace by running task with --trace)
我已经验证了listen
在我的Gemfile中的开发组中:
group :development do
gem 'listen', '~> 3.1.5'
# 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
它在我的Gemfile.lock里:
$ cat Gemfile.lock | grep 'listen'
listen (3.1.5)
spring-watcher-listen (2.0.0)
listen (>= 2.7, < 4.0)
listen (~> 3.1.5)
spring-watcher-listen (~> 2.0.0)
我已经进行了打包更新,并安装了包,并验证了gem install listen
是否有效。这一周早些时候就开始了,但我的投篮失败了。
$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
我在vendor/cache
上没有看到,但我不知道该怎么做.
$ bundle package | grep 'listen'
感谢你的帮助!
更新:
我可以通过将gem 'listen', '~> 3.1.5'
放在全局Gemfile中(并将其从:development
中删除)来“修复”这个问题。然后所有的错误都消失了,一切正常,但这似乎是错误的。
发布于 2016-07-29 19:08:15
我把这个作为一个答案,但我不喜欢它。
我可以通过将gem 'listen', '~> 3.1.5'
放在全局Gemfile中(并将其从:development
中删除)来“修复”这个问题。然后所有的错误都消失了,一切正常,但这似乎是错误的。
发布于 2017-02-28 17:14:28
如果您在rails 5上,并且使用的是默认配置/环境/Development.rb文件,那么这里将包含这一行代码。
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
这需要宝石听。当我在做rails 4升级到rails 5的时候,这让我有点不舒服。
编辑:忘了提到,如果您注释出这一行代码,它将不再需要侦听创业板。
发布于 2017-08-06 11:00:28
我用了这个:bundle install --without development
错误:
无法加载“侦听”宝石。将
gem 'listen'
添加到Gemfile的开发组(LoadError)
在此之后,使用该代码:
bundle config --delete without
bundle config --delete with
最后
bundle install
https://stackoverflow.com/questions/38663706
复制相似问题