-
Notifications
You must be signed in to change notification settings - Fork 247
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
Added paths prefixed with /private
when listening on a tmpdir (OS X)
#241
Comments
Thanks - looks like a bad bug. I couldn't reproduce it yet, so could you run it with the environment variable set: |
Here is the output with the debugging:
So a quick check shows that, on my machine at least,
I don't know the internals of the gem but it looks like |
If you check out: https://github.com/guard/listen/blob/master/lib/listen/adapter/darwin.rb#L29 the rel_path is supposed to be calculated as relative to the watched dir. Listen wasn't designed to "unresolve" symlinks, but the above line could be "fixed" to behave as expected: rel_path = new_path.relative_path_from(dir.realpath).to_s Let me know if that works (I don't use OSX at all). |
The best "approach" is to never resolve symlinks within Listen (if possible) - anything Listen returns that is symlinked should always seem "unresolved" (so the user or plugin can decide whether to resolve or not). |
Yep, I worked around it by resolving the symlink myself in my test, no big deal, was just weird, almost definitely not a problem with the gem. Does this issue/question/investigation allow you to resolve this todo? I'm happy to do a bit of testing for you if you don't have easy access to a mac. |
Does changing the line above help without the need for you to resolve the symlink yourself? (using TL; DR; I think it's not just weird, it's unexpected, so I'd like to fix this - we can keep this open until I release a fixed version (other platforms are also likely affected). Expected behavior: if you are testing for But if you're watching So from a user's perspective symlinking ideally shouldn't affect the actual paths used or returned. But all backends in Listen return event paths as resolved symlink (AFAIK), so the watched dir is the ONLY symlink which can be preserved. If it does, I'll probably just need to add a test, fix this for other platforms and release a new version. As for testing, there are probably edge cases worth testing such as:
That's because of this line: https://github.com/guard/listen/blob/master/lib/listen/directory.rb#L26 Either way, symlink handling in Listen is a tough subject, so this issue really helps make a step forward - thanks for reporting and testing this! |
I'm closing this, because it should already be fixed (meaning, even if It it doesn't work on OSX, it's probably because this needs implementing: #274 (and when it is implemented, this will be automatically resolved). |
Whilst testing some code that uses Listen I've noticed that the paths yielded from the
Listen.to
block have their paths prefixed with/private
when listening on a tmpdir.I've put together a small test case that reproduces the bug on my machine (late 2011 MacBook Pro; OS X 10.9), I've not had a chance to test this on any other platform.
My test case is below:
The text was updated successfully, but these errors were encountered: