-
Notifications
You must be signed in to change notification settings - Fork 47
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
canonicalizePath behaves strangely with paths that do not exist #23
Comments
Seeing as The alternative is to have it fallback to pure path normalization whenever it fails. I'm not a fan of this, because it means errors are silently swallowed. However, I understand that:
So perhaps we could add another function (e.g. Hence, the choice is between:
Comments? |
I very regularly want to have absolute paths to simplify other parts of the code, such as when a subprocess will be run from a different directory. I will generally use I think I prefer the idea of keeping the current function with the current behavior, and adding a new function with the new behavior. That would prevent accidentally writing code that compiles with both an old and new version of directory, but has buggy runtime behavior on an old version. |
Ah, that's a good point. But do you care about whether it dereferences symbolic links? |
It's actually irrelevant to me in that use case; I just want an absolute path. I could generally just append the relative path to the current working directory, but |
That's kind of my argument: I think Perhaps we can add another convenience function to directory:
and update the documentation in |
One small quibble.
|
@argiopetech |
I inferred the command line tool from this statement. Apologies for the misunderstanding. I'm in favor of not silently swallowing errors. I do like the idea of a Potentially this would allow us to close T5014 as WillNotFix with a reference to the new function and leave us to tackle T4215. Fortunately, T4215 may have been fixed for POSIX systems when T4113 was fixed in 96d3478. It now throws errors as in |
I retract that somewhat. Turns out it's possible for |
Edit: actually, disregard this post. Neil pointed out that this doesn't really work for symlinks. Besides
However, such a function would be entirely pure, so it's not really within the scope of directory. It should belong in filepath instead. |
|
Apply realpath to the largest prefix of the given path that is still accessible (that can be stat successfully) so that canonicalizePath will return reasonable results even for non-existent paths. It should very rarely throw exceptions now. Fixes haskell#23.
https://ghc.haskell.org/trac/ghc/ticket/4215
The text was updated successfully, but these errors were encountered: