Closed cyrusstoller closed 4 years ago
@cyrusstoller – if you look further down in the error message you should see a link to https://github.com/guard/listen/wiki/Duplicate-directory-errors, which explains why the error occurs.
For now, I've gone with adding the following to config/spring.rb
, to suppress the error:
# Listen >=2.8 patch to silence duplicate directory errors. USE AT YOUR OWN RISK
require 'listen/record/symlink_detector'
module Listen
class Record
class SymlinkDetector
def _fail(_, _)
raise Error, "Don't watch locally-symlinked directory twice"
end
end
end
end
… which is a suggestion from the link mentioned above, but not recommended.
Thanks for sharing. I don't feel great about using that solution. Are there other ways to approach this?
@cyrusstoller – agreed, this is less than ideal. Unfortunately I didn't come across any other solutions in my (admittedly limited) investigations.
The link from the guard
wiki above suggests that this has something to do with symlinks. But I'm not quite sure why there would be a symlink within a node module (I've possibly hit a limit in my understanding/knowledge here); my hunch is there's a deeper problem/bug at play here.
Looking at the errors closely, I see:
Directory: /Users/jits/Projects/…/node_modules/.bin/compression-webpack-plugin
is already being watched through: /Users/jits/…/patch-list/node_modules/compression-webpack-plugin
Directory: /Users/jits/Projects/…/node_modules/.bin/mini-css-extract-plugin
is already being watched through: /Users/jits/…/node_modules/mini-css-extract-plugin
… looks like it's mistaking the executables within the .bin
directories of node modules for directories – very likely a bug in listen
.
@cyrusstoller – are you seeing this too when you get the error?
Will try to find time later to investigate further and file a bug report.
I'm seeing the same thing. Any tips on how I can help investigate?
I would exempt node_modules
from being watched. Even if it eventually works, you are wasting perf & memory watching something that shouldn't be changing.
Makes sense. I don't think I'm currently watching the node_modules from guard. I'll look for other places.
Here's my Guardfile:
guard :minitest, spring: "bin/rails test" do
notification :terminal_notifier,
activate: 'com.googlecode.iTerm2' if `uname` =~ /Darwin/
# Rails 4+
watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
watch(%r{^test/.+_test\.rb$})
watch(%r{^test/test_helper\.rb$}) { 'test' }
end
@jakeNiemiec –
I would exempt
node_modules
from being watched. […]
This would be ideal! I don't think there's a way to do this in Rails apps?
I don't think there's a way to do this in Rails apps?
@jits I changed my stack to let node do all the watching/proxying/reloading with https://github.com/Va1/browser-sync-webpack-plugin
It also excludes node_modules
by default: https://www.browsersync.io/docs/options/#option-watch
This seems like it might be related: https://github.com/rails/rails/issues/32700
There may be a fix for this (if you're using factory_bot):
https://github.com/thoughtbot/factory_bot_rails/releases/tag/v5.0.2
Can this issue be closed ?
I think so. I'm no longer experiencing this issue anymore using the latest versions of Rails.
Feel free to close it then 👍
Thanks @guillaumebriday for reviewing issues 🍰
For anyone following this thread, guard and listen warnings are now configurable as of listen v3.9.0.
This is a fantastic project. I really appreciate being able to develop using Vue and Rails in the same project.
I'm in the process of upgrading to 4.x. I followed the guide and things appear to be functioning properly. However, I'm running into an "error" when using Guard to run my tests and when opening a new rails console.
In my terminal that's running my tests I see the following a few times:
And then I also see it if I open a new rails console.
What's strange to me is that it doesn't really seem to be causing any errors. I'm still able to interact with my project. The node_modules that it calls out are:
This is more of a minor annoyance than anything else. What's odd is if I close the rails console and then open a new rails console the errors don't appear. I'm assuming this has something to do with me using the default spring settings.
I'm not sure what will be most helpful for me to provide to help debug.
Here are some basics:
Any tips for how to resolve these?