Skip to content
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

UPath failures on windows (must be absolute) with Subsystem #40

Closed
LimpingNinja opened this issue Aug 5, 2019 · 6 comments
Closed

UPath failures on windows (must be absolute) with Subsystem #40

LimpingNinja opened this issue Aug 5, 2019 · 6 comments

Comments

@LimpingNinja
Copy link

LimpingNinja commented Aug 5, 2019

I'm using a physical file system and a subsystem and if I'm using OSX it works perfectly fine, but on Windows it fails with 'Path 'c:/path/here' must be absolute'

var path = "c:/path/here/"
fs = new PhysicalFileSystem();
subfs = new SubFileSystem(fs, path);

This also fails on slower 'C:\path\here\'

I thought it was the trailing slash removal until I followed and noted that AssertAbsolute throws even with the trailing slash since the path does not start with / but c:/

@LimpingNinja
Copy link
Author

LimpingNinja commented Aug 5, 2019

'/mnt/c/path/here'

Also does not work, I see the documentation say that this typically does but I'm not sure why unless you were specifically running it under WSL which doesn't seem correct for x-platform. Looks like the assumptions made for this specifically tie across the library.

@GerardSmit
Copy link
Contributor

GerardSmit commented Aug 9, 2019

I'm using a physical file system and a subsystem and if I'm using OSX it works perfectly fine, but on Windows it fails with 'Path 'c:/path/here' must be absolute'

This is by design. The README says the following:

With uniform paths, this filesystem on Windows is working like on a Windows Subsystem Linux

Note the word "like", it doesn't say Zio does this only on WSL. You always use the unix path-style, even on Windows.

'/mnt/c/path/here'
Also does not work, I see the documentation say that this typically does but I'm not sure why unless you were specifically running it under WSL which doesn't seem correct for x-platform. Looks like the assumptions made for this specifically tie across the library.

Do you get an exception? Does the program has access to the folder?

When I tried the latest version on .NET Core 2.2.5 (x64) it's working fine:

image

@LimpingNinja
Copy link
Author

This is by design. The README says the following

Yes, I cited that in my update; that's my fault.

Do you get an exception? Does the program has access to the folder?

It has access, but ultimately it appeared to be my fault here - sorry for the false message; I somehow missed a directory exist call that was using standard filesystem check vs. the Zio check.

@OlivierLePichon
Copy link

Facing with exactly same problem on Windows.

I understand I must use a subPath formatted as "/mnt/c/path/here" to SubFileSystem ctor but my question is:

Is there a simple way to convert "c:\path\here\" to "/mnt/c/path/here"?

@xoofx
Copy link
Owner

xoofx commented Jan 17, 2024

Is there a simple way to convert "c:\path\here" to "/mnt/c/path/here"?

UPath ConvertPathFromInternal(string systemPath);

fs.ConvertPathFromInternal("/mnt/c/path/here") should do it assuming that fs is a PhysicalFileSystem

@OlivierLePichon
Copy link

OlivierLePichon commented Jan 17, 2024

Thanks!
In my case, fs.ConvertPathFromInternal("c:\path\here") produce exactly what I was expected: "/mnt/c/path/here"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants