You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The prefix file:// results in ignoring the first path component. #108
I do have a pretty good idea where the error is occurring here, but I'd love to have some more information from you beforehand.
Could you tell me what the first thing you tried was, before you were investigating the behavior of the different amount of slashes after file:, i.e. how did you generate your URIs?
Basically file://var/tmp is interpreted as host=var and path=/tmp and we currently seem to ignore the host for local paths. The question is, how we should address this in the best way. Very likely with both: better documentation AND actually using the host and erroring with a clear error msg.
I initially tried "file://" expecting it to follow other url-like parameters. If the implementation interprets the first string as hostname it should make sure that the value is usable and throw an error otherwise. i.e. if hostname != 'localhost' and hostname != '' then it should imho raise an ArgumentError.
A pathname consisting of a single slash shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.
So does that mean file://localhost/absolute/path/file.txt would actually not map to /absolute/path/file.txt on posix systems, but to the path //localhost/absolute/path/file.txt?
how does that fit together with rfc8089? Are "file" ":" "//" "auth-part" -style URIs with a host not compatible with posix?
I've never come across file URIs that use file://localhost/ in the wild, but they should probably be handled specially. I'll adjust the PR.
The RFC also says:
The "host" is the fully qualified domain name of the system on which
the file is accessible. This allows a client on another system to
know that it cannot access the file system, or perhaps that it needs
to use some other local mechanism to access the file.
... which works fine on Windows, but not on other systems :(
Activity
ap-- commentedon Jun 21, 2023
Hi @pedro-r-marques
thank you for opening an issue!
I do have a pretty good idea where the error is occurring here, but I'd love to have some more information from you beforehand.
file:, i.e. how did you generate your URIs?Basically
file://var/tmpis interpreted ashost=varandpath=/tmpand we currently seem to ignore the host for local paths. The question is, how we should address this in the best way. Very likely with both: better documentation AND actually using the host and erroring with a clear error msg.Cheers,
Andreas 😃
pedro-r-marques commentedon Jun 22, 2023
I initially tried "file://" expecting it to follow other url-like parameters. If the implementation interprets the first string as hostname it should make sure that the value is usable and throw an error otherwise. i.e. if hostname != 'localhost' and hostname != '' then it should imho raise an ArgumentError.
ap-- commentedon Aug 28, 2023
Notes:We should provide a correct error message for now, and in case pathlib or we decide to support parsing relative path uri's we can switch, see:662c294#r123906140 expecting support forfile:path/file.txtGH-107465: Addpathlib.Path.from_uri()classmethod. python/cpython#107640moved to new issue #142
barneygale commentedon Sep 2, 2023
file://foo/bardoes not represent a relative path on Windows - it represents a UNC path\\foo\bar.In my CPython PR I made it work the same on POSIX, and so:
Note that paths with two leading slashes are allowed by POSIX:
ap-- commentedon Sep 3, 2023
Thanks for the clarification @barneygale!
So does that mean
file://localhost/absolute/path/file.txtwould actually not map to/absolute/path/file.txton posix systems, but to the path//localhost/absolute/path/file.txt?how does that fit together with rfc8089? Are
"file" ":" "//" "auth-part"-style URIs with a host not compatible with posix?barneygale commentedon Sep 3, 2023
I've never come across file URIs that use
file://localhost/in the wild, but they should probably be handled specially. I'll adjust the PR.The RFC also says:
... which works fine on Windows, but not on other systems :(
ap-- commentedon Feb 15, 2024
Fixed in
universal_pathlib==0.2.0. Behavior for "file://path" uris is now identical to fsspec.