Skip to content

Use common Windows Subsystem path helper for calling tools on Windows #3300

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

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

arixmkii
Copy link
Contributor

@arixmkii arixmkii commented Mar 3, 2025

Fixes #3164
Fixes #3167
Fixes #3215

This unifies use of cygpath tool through the codebase. As currently there will be no support for Windows fork of OpenSSH (missing a lot of features, not only mux, but also basic AF_UNIX) and in future if such support is considered it will have conditional handling in he codebase.

I switched the tool to generate Unix like paths instead of hybrid ones. They are fully understand by msys2 tooling, so are safe to use to all tools in use. Additionally this opened opportunity to use wslpath as drop-in replacement of cygpath and provides capabilities to use tooling hosted inside WSL container, where full set of feature is available, which in turns makes QEMU support easier to achieve (mux for port forwarding with SSH forwarder, etc).

There is some special handling added for /mnt/ prefixes, because it is the difference between cygpath and wslpath outputs. So, it is a compatibility supporting part.

@arixmkii arixmkii force-pushed the windows-susbsystem-path branch from 67bdd85 to f75c748 Compare March 3, 2025 16:50
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
@arixmkii arixmkii force-pushed the windows-susbsystem-path branch from f75c748 to 9f52194 Compare March 3, 2025 16:53
@AkihiroSuda AkihiroSuda added this to the v1.1 (tentative) milestone Mar 4, 2025
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit ebb8f49 into lima-vm:master Mar 4, 2025
31 checks passed
Comment on lines +203 to +205
if err == nil && !strings.HasPrefix(dir, "/mnt/") {
dir = path.Join("/mnt", dir)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get a chance to review this PR properly, but wanted to comment that the /mnt prefix is just a default setting; it can be changed (or disabled) by the user in /etc/wsl.conf:

[automount]
enabled = true
root = /windir

So in general the directory name cannot be determined without checking /etc/wsl.conf inside the distro where you want to use it first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware of this setting, yet to see it in real life, though.

I was focused on the "default" configuration with this change. I have a fix in mind, will submit it this week and ask you to review #3303

@arixmkii arixmkii deleted the windows-susbsystem-path branch March 6, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants