-
Notifications
You must be signed in to change notification settings - Fork 701
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
Fix file+noindex URI usage on Windows #10728
base: master
Are you sure you want to change the base?
Conversation
8cacda3
to
fe6eed7
Compare
fe6eed7
to
0b33fff
Compare
0b33fff
to
5558a47
Compare
reponame | ||
-- Normalization of Windows paths that use @//./@ does not fully | ||
-- normalize the path (see filepath#247), but it is still usable. | ||
(normalise (uriPath uri)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key point of this PR is this call to normalise
.
ghci> readFile "//./C:/some/path"
*** Exception: //./C:/some/path: openFile: does not exist (No such file or directory)
ghci> readFile $ normalise "//./C:/some/path"
"The contents of the file in C:/some/path\n"
Notice this was broken on Windows #10095 (comment), see how the paths in the output do not have a |
5558a47
to
82788ec
Compare
82788ec
to
37ab8b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I wonder if we can pull in some of Andrea’s PRs after this fix…
@@ -200,6 +200,10 @@ repository. | |||
``package-name-version.tar.gz`` files in the directory, and will use optional | |||
corresponding ``package-name-version.cabal`` files as new revisions. | |||
|
|||
.. note:: | |||
On Windows systems, the path has to be prefixed by ``//./`` as in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changelog says “can”, but docs says “has to”. These are different things, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to say that now they can use local+noindex repos, previously they couldn't. And if they want to use it they have to use that syntax.
Isn't the wording right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the "if" part that you say here (if they want to use it they have to use that syntax
) is not in the docs. The docs just say "has". Could you add the "if" part?
37ab8b4
to
7349d88
Compare
390ce77
to
85d3807
Compare
85d3807
to
a03d515
Compare
a03d515
to
19c9a86
Compare
-- normalized) as a POSIX path, for example in URIs. | ||
asPosixPath :: FilePath -> FilePath | ||
asPosixPath p = | ||
[if x == Windows.pathSeparator then Posix.pathSeparator else x | x <- p] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs don't recommend direct comparison but to use isPathSeparator instead.
Rather than using (== pathSeparator), use this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im fine using isPathSeparator
but keep in mind that
> Windows.isPathSeparator Posix.pathSeparator
True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that too. I'm OK either way. Maybe a short comment attached to your choice?
-- | Sometimes we need to represent a Windows path (that might have been | ||
-- normalized) as a POSIX path, for example in URIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any added tests with this pull request. Would it be possible to add some? How about a doctest example attached to the haddocks of asPosixPath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that for asPosixPath
. The tests in PackageTests now pass without the hack in the output normalizer, I consider that sufficient enough proof for this small change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you point me to a failed CI run or test before this fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be what you are looking for? https://github.com/haskell/cabal/actions/runs/12402807907/job/34625090748?pr=10647 It stopped failing when a hack was put in place, the lines I remove in the OutputNormalizer
Also you might want to look at this comment and above in the Cabal matrix channel https://matrix.to/#/!YWYQDCuIpuQHzGrLzd:matrix.org/$TFlqqD7_hY3361aMFALPvP4Yzr3Ib7zMTNlu-_x0q-I?via=matrix.org&via=kf8nh.com&via=tchncs.de
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(On the other hand, asPosixPath
is so trivial that I don't see a huge benefit adding doctests, but if you insist I will do it)
|
||
- Windows users can now specify file+noindex paths using the format `file+noindex:////./C:/path/to/repo`. | ||
This syntax comes from https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths, | ||
and is the only syntax for DOS paths fully supported by the `network-uri` package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and is the only syntax for DOS paths fully supported by the `network-uri` package. | |
and is the only syntax for DOS paths fully supported by the `network-uri` package, | |
which Cabal uses to handle paths. |
This PR fixes the parsing of URIs for file+noindex repositories when using Windows paths. As suggested by @phadej in #10703 we now use (and specify in the docs)
//./C:/...
paths on Windows.QA
In Windows, one can now specify
//./
paths in file+noindex repositories. To check, create a simple package, thencabal sdist
, move the tar.gz to some directory and in a different project declare the following stanza:It might still fail because of #9891
Template Α: This PR modifies behaviour or interface
Include the following checklist in your PR:
significance: significant
in the changelog file.