diff --git a/Cargo.lock b/Cargo.lock index d3860be59fe..57d9c49ff1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5558,18 +5558,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.19.15", -] - [[package]] name = "toml" version = "0.8.15" @@ -5598,8 +5586,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.2.6", - "serde", - "serde_spanned", "toml_datetime", "winnow 0.5.40", ] @@ -6827,9 +6813,9 @@ dependencies = [ [[package]] name = "wasmer-config" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a0f70c177b1c5062cfe0f5308c3317751796fef9403c22a0cd7b4cacd4ccd8" +checksum = "4b4a632496950fde9ad821e195ef1a301440076f7c7d80de55239a140359bcbd" dependencies = [ "anyhow", "bytesize", @@ -7425,12 +7411,12 @@ dependencies = [ [[package]] name = "webc" -version = "6.0.0-rc1" +version = "6.0.0-rc3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fc686c7b43c9bc630a499f6ae1f0a4c4bd656576a53ae8a147b0cc9bc983ad" +checksum = "b85ffb11d1fabf0ebfc458a3d1d34ccf6d4d9596ca7576370cae4eab554c63d1" dependencies = [ "anyhow", - "base64 0.21.7", + "base64 0.22.1", "bytes 1.6.1", "cfg-if 1.0.0", "document-features", @@ -7452,9 +7438,9 @@ dependencies = [ "tar", "tempfile", "thiserror", - "toml 0.7.8", + "toml 0.8.15", "url", - "wasmer-config 0.2.0", + "wasmer-config 0.4.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ae9309443c6..b0699951d0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ wasmer-config = { path = "./lib/config" } wasmer-wasix = { path = "./lib/wasix" } # Wasmer-owned crates -webc = { version = "6.0.0-rc1", default-features = false, features = ["package"] } +webc = { version = "6.0.0-rc3", default-features = false, features = ["package"] } edge-schema = { version = "=0.1.0" } shared-buffer = "0.1.4" diff --git a/lib/wasix/src/runners/wasi.rs b/lib/wasix/src/runners/wasi.rs index 85d35129b37..7713b80f6d2 100644 --- a/lib/wasix/src/runners/wasi.rs +++ b/lib/wasix/src/runners/wasi.rs @@ -354,6 +354,10 @@ impl crate::runners::Runner for WasiRunner { } } + if let Some(cwd) = &wasi.cwd { + env.set_current_dir(cwd); + } + let env = env.build()?; let store = runtime.new_store(); diff --git a/tests/integration/cli/tests/packages/list-cwd/main.c b/tests/integration/cli/tests/packages/list-cwd/main.c new file mode 100644 index 00000000000..fcfbdb4f9ab --- /dev/null +++ b/tests/integration/cli/tests/packages/list-cwd/main.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + DIR *dir; + struct dirent *entry; + + dir = opendir("./"); + if (dir == NULL) + { + perror("opendir"); + return 1; + } + + while ((entry = readdir(dir)) != NULL) + { + printf("%s\n", entry->d_name); + } + + closedir(dir); + + return 0; +} diff --git a/tests/integration/cli/tests/packages/list-cwd/main.wasm b/tests/integration/cli/tests/packages/list-cwd/main.wasm new file mode 100644 index 00000000000..9ae1b7c3b55 Binary files /dev/null and b/tests/integration/cli/tests/packages/list-cwd/main.wasm differ diff --git a/tests/integration/cli/tests/packages/list-cwd/wasmer.toml b/tests/integration/cli/tests/packages/list-cwd/wasmer.toml new file mode 100644 index 00000000000..3f6d3798b92 --- /dev/null +++ b/tests/integration/cli/tests/packages/list-cwd/wasmer.toml @@ -0,0 +1,14 @@ +[[module]] +name = "main" +source = "main.wasm" + +[fs] +"/data" = "." + +[[command]] +name = "run" +module = "main" +runner = "wasi" + +[command.annotations.wasi] +cwd = "/data" \ No newline at end of file diff --git a/tests/integration/cli/tests/run.rs b/tests/integration/cli/tests/run.rs index 2da4bb75f5f..b43f9d3750f 100644 --- a/tests/integration/cli/tests/run.rs +++ b/tests/integration/cli/tests/run.rs @@ -47,6 +47,29 @@ static CACHE_RUST_LOG: Lazy = Lazy::new(|| { .join(",") }); +#[test] +fn list_cwd() { + let package = packages().join("list-cwd"); + + let output = Command::new(get_wasmer_path()) + .arg("run") + .arg(package) + .output() + .unwrap(); + + let stdout = output.stdout; + + let expected = ". +.. +main.c +main.wasm +wasmer.toml +" + .to_owned(); + + assert_eq!(expected, String::from_utf8(stdout).unwrap()); +} + #[test] fn nested_mounted_paths() { let package = packages().join("nested-mounted-paths");