-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guard confused by symlinked folders #787
Comments
At this level you're quickly getting into complexities that are normally hidden from average users.
First, you've created a "filesystem loop". Any tool which recurses and follows symlinks will loop infinitely. The UNIX tool Listen should detect this and fail with an error - which means it simply won't respond to changes. I didn't find a reference in the Puppet tutorial you mentioned that says to make such a symlink - I'd avoid it anyway. Second, Listen strongly discourages physically watching the same directory more than once - this doesn't make sense and it's a waste of resources. It's convenient to watch "a whole project", but you usually only want to watch a few specific directories. If you want a specific layout, I'd suggest moving the physical directories into a special directory (e.g. Symlink support is extremely difficult to implement in a way that makes people happy - one reason is that the OSX implementation forces recursion anyway, and My suggestions are:
In short - make heavy use of symlinks to defining a structure to match the workflow, while completely avoiding symlinks in watched directories. File-monitoring and symlinks just will never work "as expected". You can pretty much blame Apple for that. Let me know if that helps. |
Thanks for entering the deep end ;)
Again thank you. |
With symlinks you'll have exactly the same layout - with the exception of an additional folder with the "originals". Unlike other tools,
Again, the OSX adapter is recursive - and so there's no way to "physically" ignore a subtree. Basically, watching the project root dir means watching the whole project tree. And since the OSX driver is recursive, it doesn't make sense for recursion to be configurable (e.g. on Linux). Also, since you can create or rename an ignored directory at any time, handling all the edge cases becomes extremely complex quickly (adding/removing folders from being watched, etc.) - reorganizing a project layout is a much better investment hands down, every time. Also, For a simpler configuration, you can probably use something like directories Dir['spec/*'].reject { |d| d =~ /^spec\/fixtures\// } # + (...) It maybe wouldn't be hard to implement Linux-only configuration options and intelligently avoid watching already-watched directories. I wouldn't mind accepting PRs for this - my own todo list is already a mile long though for me to tackle this myself. I still think the need for symlinks can be replaced with better project configuration (there shouldn't be a need to symlink the whole project within |
Yeah, I've already reorganised some of my projects and I start liking it as I can put
OK, now I got it. At the end, again, I'd like to thank you for taking time to deep-diving the topic here. |
Hope filing the issue here is correct.
When setting up my dev environment (current Ubuntu 14LTS, XFS filesystem, current rvm with ruby 2.2.1 and current gems) for coding puppet modules I ran into problems indicated by duplicate directories error.
That's why I follow puppet module development recommendations. When I get to the point of using rspec, I've got following puppet module structure (tool based creation):
When starting guard and the directory symlink
spec/fixtures/modules/my_module
already exists then guard (listen gem) is not able to recognize file modifications within my entire module path.On guard pry console
Guard.state.session.watchdirs
shows correct path.When creating
spec/fixtures/modules/my_module
after starting guard (usually usingrake spec_prep
), guard (listen) is sometimes working as expected. Sometimes guard doesn't recognize changes to manifest files (manifests/*.pp
), sometimes changes to manifest's spec files (spec/*_spec.rb
). So this work-around is not stable.I've just found your Understanding-Guard guide. Great, I've found out, that using
-p
option will allow guard to work properly even if symlinkedspec/fixtures/modules/my_module
exists before starting guard. And this seems to be stable behaviour.I couldn't work out answers to my follow up questions. Maybe, you could answers them. I would like to know:
-p
? There should be any (like increased CPU usage?), otherwise polling would be default behaviour of guard.The text was updated successfully, but these errors were encountered: