-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Leading slash in std::env::current_dir
output on Windows
#10415
Comments
Thanks for the report, and thank you for minimizing this as well, it's much appreciated! I fear though that I may not have great news for you as this is not going to be an easy bug to fix. Unfortunately this has nothing to do with Wasmtime, it's got everything to do with the guest program itself. However it's also not entirely fair (IMO) to "point the finger of blame" at the guest program. In the end this is basically a situation that's not super well supported today. To elaborate on that, what's happening here is, as you've seen, a clash of Windows an Unix paths. Windows understands that the leading The question is then somewhat: "who should do this translation?" A reasonable answer is "wasmtime!" but unfortunately the tools aren't in place for that right now. For example to Wasmtime this is "just another env var" being passed to the program and it has no idea that So in essence the problem you're running into is that when giving access to the whole filesystem to windows guest someone or something will have to do translation of windows paths. As-is today something would have to translate cc @sunfishcode this seems like the kind of bug/issue you might be interested in being aware of |
Thank you for the reply, @alexcrichton!
This is pretty much what I expected, but wanted to make get confirmation by opening this issue rather than simply assuming 🙂 |
We use Wasm and Wasmtime to power the extension system in Zed and are seeing some undesired behavior with
std::env::current_dir
when executing Wasm on Windows.I have created a minimized test case that I believe showcases the issue. The repo can be found at maxdeviant/wasmtime-current-dir-repro. It contains CI set up to run the reproduction case on Windows, as well as on macOS and Linux to contrast the behaviors.
If the Wasmtime repo isn't the right place for this issue, let me know where I can redirect it.
Test Case
In the reproduction repo above, I have the following Rust program:
When run on Windows with the
PWD
environment variable set toD:/a/wasmtime-current-dir-repro/wasmtime-current-dir-repro
this is the output of the program:Steps to Reproduce
cargo build --target wasm32-wasip1
wasmtime run --dir=$PWD --env PWD ./target/wasm32-wasip1/debug/wasm-current-dir-repro.wasm
std::env::current_dir
path in theAfter:
line contains a leading slashExpected Results
std::env::current_dir
returnsD:/a/wasmtime-current-dir-repro/wasmtime-current-dir-repro
as the path.Actual Results
std::env::current_dir
returns/D:/a/wasmtime-current-dir-repro/wasmtime-current-dir-repro
as the path (note the leading slash).Versions and Environment
Wasmtime version or commit:
wasmtime 30.0.2 (398694a59 2025-02-25)
Operating system: Windows 10
Architecture: x64
Extra Info
I also tried testing this with
--target wasm32-wasip2
to see if it would make a difference, and it did not: the output remained the same on Windows (containing a leading slash).The text was updated successfully, but these errors were encountered: