问题描述
我有一个API模式的Rails 5应用程序,该应用程序不允许我运行rake routes
或rails s
.我得到的错误是:
I've got an API mode Rails 5 app that won't let me run rake routes
or rails s
. The error I get is:
$ 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的开发组中:
I've verified that listen
is in the development group in my 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中:
And that it's in my 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
是否有效.这在本周早些时候有效,但是我在提交过程中没有运气.
I've bundle updated, and bundle installed, and verified that gem install listen
works. This was working earlier this week, but I'm not having luck going back through my commits.
$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
我在vendor/cache
中看不到它,但是我不确定该怎么做...
I don't see it in vendor/cache
but I'm not sure what to make of that...
$ bundle package | grep 'listen'
感谢帮助!
更新:
我可以通过将gem 'listen', '~> 3.1.5'
放入全局Gemfile中(并将其从:development
中删除)来解决"该问题.然后所有错误消失,一切正常,但这似乎是错误的.
I can "fix" the problem by putting gem 'listen', '~> 3.1.5'
in the global Gemfile (and removing it from :development
). Then all the errors go away and everything works, but that seems wrong.
推荐答案
我将其发布为答案,但我不喜欢它.
我可以通过将gem 'listen', '~> 3.1.5'
放入全局Gemfile中(并将其从:development
中删除)来解决"该问题.然后所有错误消失,一切正常,但这似乎是错误的.
I can "fix" the problem by putting gem 'listen', '~> 3.1.5'
in the global Gemfile (and removing it from :development
). Then all the errors go away and everything works, but that seems wrong.
这篇关于LoadError:无法加载“监听" gem(导轨5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!