-
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 is no longer canonical for directories (trailing slashes) #63
Comments
Possibly related to #42 |
It is not actually canonical for directories with vs without a trailing slash. This bug is present in newer directory releases, older versions work correctly. Filed as haskell/directory#63
It is not actually canonical for directories with vs without a trailing slash. This bug is present in newer directory releases, older versions work correctly. Filed as haskell/directory#63
Sorry, I don't think there's a sensible way to fix this. The idea of “canonicalization” has always been quite vague and there does not seem to be an agreement on whether trailing slashes carry significant meaning. The current behavior aligns with that of directory 1.2.2.1 or older. Between 1.2.3.0 and 1.2.5.0 the behavior was different, which was an unintentional result (#42) of fixing #23. The current behavior is now fully documented:
I suggest running |
Surely it's just a matter of integrating
The canonicalization is not that vague. Everyone accepts that file systems have multiple names that refer to the same file system object (hard links etc), but programmers and users have reasonable expectations about things that are really the same name.
There doesn't need to be any such agreement. It's clearly not canonical to preserve them. They should either always be there or never (the old behaviour was never). I'm fully aware about the vagaries of whether trailing slashes should carry meaning or not, but that really ought to be irrelevant for a function that is there to produce a canonical result.
No it does not. In particular the following versions have the correct behaviour (ie same result for input paths given with or without trailing slash):
It is only the version shipped with ghc-8.0.1 that has the new incorrect behaviour of non-canonical results. So it's quite clear the old behaviour is possible, and well established. We need canonical results. Lots of apps rely on this. We need a form where we can compare strings and have those refer to the same name. To the best of my knowledge the old It's not ok to just say "oh the behaviour changed, please add a call to dropTrailingPathSeparator", when there's no good reason for the change and particularly because it's a silent behaviour change that subtly breaks an important property. If we really thought that it was unsustainable to have a function that tries to produce canonical names then it'd be fine to add a few replacements and deprecate the old one. But I've not yet seen any argument that this is the situation here. |
You're right. The quirky behavior did not exist prior to 1.2.2.1. Sorry, I did not verify the old behavior (I took #42 for granted). My guess is that the quirk had existed only on Windows systems. In that case I will revert the fix for #42 and bump the major version. |
Ok great, but presumably we don't want to re-introduce the odd behaviour described in #42. It should still be the case that BTW, I noticed this in the implementation of
Specifically, |
It used to matter, but now it's redundant because of the |
Let me know if Rufflewind@43488ba fixes it. In particular, the tests have been updated to reflect the change in behavior. |
It is not actually canonical for directories with vs without a trailing slash. This bug is present in newer directory releases, older versions work correctly. Filed as haskell/directory#63
@dcoutts any update on this? I'd like to be able to get a new release candidate out soon. |
After discussion with Duncan Coutts, it was found that the trailing slash-preserving behavior was actually a bug on Windows. This means there is really no reason for the current, somewhat quirky behavior of preserving trailing slashes. However, it has been a while since the change was made, so it would be safer to introduce this as a major version bump. The internal prependCurrentDirectory function has been reworked slightly with regards to the behavior on empty paths, but this not have any visible effect on the public API since they always end up normalizing the result of prependCurrentDirectory in some way or another. Fixes haskell#63.
The bug has been fixed (Rufflewind@43488ba), but I wanted to use the opportunity to also fix some other deficiencies with |
@Rufflewind, do you think we could just move ahead with a release so that I can push another release candidate out? |
It is not actually canonical for directories with vs without a trailing slash. This bug is present in newer directory releases, older versions work correctly. Filed as haskell/directory#63
It is not actually canonical for directories with vs without a trailing slash. This bug is present in newer directory releases, older versions work correctly. Filed as haskell/directory#63
It used to be the case that
canonicalizePath
for directories would return the directory without the trailing slash, irrespective of whether the directory was given with or without the trailing slash. As of some version, but certainly including 1.2.6 and still in 1.2.7.1 the result sometimes includes a trailing slash and sometimes does not. This violates the property that the result be canonical.This canonical property is important, lots of code relies on it. As an example of the kind of bug it causes:
This happens because this code relies on the canonical property to match up packages that are known to live at various locations with a directory given by the user. Since one code path happens to call
canonicalizePath
with a trailing slash and another without then there is no match and the confusing error.The text was updated successfully, but these errors were encountered: