Stream: git-wasmtime

Topic: wasmtime / PR #9831 Implement initial-cwd for wasi:cli/en...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2024 at 10:56):

stephenmuss opened PR #9831 from stephenmuss:initial-cwd to bytecodealliance:main:

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
This implements initial-cwd for wasi:cli/environment.

My biggest struggle was finding the appropriate places to add tests. Any guidance would be appreciated. Thank you.

Closes #9695

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2024 at 10:56):

stephenmuss requested fitzgen for a review on PR #9831.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2024 at 10:56):

stephenmuss requested wasmtime-core-reviewers for a review on PR #9831.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2024 at 15:55):

alexcrichton commented on PR #9831:

Thanks! I'd recommend adding a test to crates/test-programs/bin/*.rs and there's a small README about the tests in that directory.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 17 2024 at 00:15):

stephenmuss commented on PR #9831:

I assume I should be able to use something like this in crates/test-programs/bin/*.rs to test

fn main() -> std::io::Result<()> {
    let cwd = std::env::current_dir()?;
    assert_eq!(cwd.to_str(), Some("/tmp"));
    Ok(())
}

and run with -S cwd=/tmp.

Is that understanding correct?

However, I always get Some("/") indicating that I still need to set the path somewhere I've missed, presumably in src/commands/run.rs and src/commands/serve.rs etc.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 17 2024 at 15:25):

alexcrichton commented on PR #9831:

Ah you'll probably need to use the WASI API directly rather than the standard library because the standard library isn't hooked up to this API yet.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 09 2025 at 22:26):

Timmmm commented on PR #9831:

Does the WASI API actually exist yet? Your issue about it is still open. Also as far as I can tell initial_cwd() isn't actually called from anywhere (though I may have missed it if there's some proc macro magic or something).

view this post on Zulip Wasmtime GitHub notifications bot (Feb 10 2025 at 15:32):

alexcrichton commented on PR #9831:

It exists insofar as the *.wit function exists and is stable. The issue you linked is from a long time ago and was intended for *.witx or effectively WASIp1. WASIp1 isn't going to change any more but this function was added to enhance the functionality and largely solve that issue in WASIp2.

To the extent the function exists, however, I'm also not familar with any integration with it. For example wasi-libc does not call the function and try to use the return value (nor does Rust's libstd). Hooking it up to Wasmtime, however, is step 1 in filling out ecosystem support for it though as otherwise it can't even be tested.


Last updated: Feb 28 2025 at 02:27 UTC