Ruby-on-rails 侦听错误:无法监视目录的更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42225677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Listen error: unable to monitor directories for changes
提问by current_user
I am getting the following error while running my rails app in Ubuntu server
在 Ubuntu 服务器中运行 Rails 应用程序时出现以下错误
FATAL: Listen error: unable to monitor directories for changes. Visit https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchersfor info on how to fix this.
致命:侦听错误:无法监视目录的更改。 有关如何解决此问题的信息,请访问 https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers。
I have followed the above GitHub page, but I was unable to write in max_user_watches which were set in 8192 and I want to set that to 524288.
in cat /proc/sys/fs/inotify/max_user_watchesthe file was in only read mode.I tried to grant write permissions, but I was getting permission denied error even with root access.
我已经关注了上面的 GitHub 页面,但我无法在 8192 中设置的 max_user_watches 中写入,我想将其设置为 524288。cat /proc/sys/fs/inotify/max_user_watches文件处于只读模式。我试图授予写权限,但我得到了即使有 root 访问权限也被拒绝错误。
Thanks in Advance!!!
提前致谢!!!
回答by Mayur Shah
1000 is way too small, try with 524288 as explained in the wiki page: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
1000 太小了,请按照维基页面中的说明尝试使用 524288:https: //github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
Listen uses inotify by default on Linux to monitor directories for changes. It's not uncommon to encounter a system limit on the number of files you can monitor. For example, Ubuntu Lucid's (64bit) inotify limit is set to 8192.
If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal:
在 Linux 上,Listen 默认使用 inotify 来监视目录的变化。遇到系统限制您可以监视的文件数量的情况并不少见。例如,Ubuntu Lucid(64 位)的 inotify 限制设置为 8192。
如果您运行的是 Debian、RedHat 或其他类似的 Linux 发行版,请在终端中运行以下命令:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
If you are running ArchLinux, run the following command instead
如果您正在运行 ArchLinux,请改为运行以下命令
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system
回答by Pasupathi Thangavel
Just try to execute this from your console
尝试从您的控制台执行此操作
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Hope this will work for you .
希望这对你有用。
References: click here
参考资料:点此
回答by Ian Link
For others who may have this issue. I had a VM disconnect which left the previous rails server running. Running below resolved the issue without needing to up the number of watcher.
对于可能有此问题的其他人。我有一个 VM 断开连接,使之前的 Rails 服务器运行。下面运行解决了这个问题,而无需增加观察者的数量。
kill -9 $(lsof -i tcp:3000 -t)
回答by Travis Le
In my case, I just need to turn off the terminal and then start it back again. It works when I try to run rails ccommand :)
就我而言,我只需要关闭终端,然后重新启动它。当我尝试运行rails c命令时它有效:)
回答by jamesc
This error occurred for me as I had a number of ruby processes currently running that I was unaware of. Just need to terminate them and all is good
这个错误发生在我身上,因为我有许多我不知道的 ruby 进程正在运行。只需要终止它们,一切都很好

