diff --git a/Cargo.lock b/Cargo.lock index 742a1f4b0..fc933c282 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4324,6 +4324,7 @@ dependencies = [ "flate2", "hex", "http_req", + "indexmap", "isatty", "libc", "log", @@ -4608,11 +4609,12 @@ dependencies = [ [[package]] name = "wasmer-toml" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d0f664e5dfad0339727ad2f4f8a7d982b4c120d87b800380e306c0dc038a49" +checksum = "4232db0aff83ed6208d541ddcf1bf72730673528be8c4fe13c6369060f6e05a7" dependencies = [ "anyhow", + "indexmap", "semver 1.0.14", "serde", "serde_cbor", diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index a1960afa9..49d4fad8a 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -63,7 +63,8 @@ dirs = { version = "4.0" } serde_json = { version = "1.0" } target-lexicon = { version = "0.12", features = ["std"] } prettytable-rs = "0.9.0" -wasmer-toml = "0.5.0" +wasmer-toml = "0.6.0" +indexmap = "1.9.2" walkdir = "2.3.2" regex = "1.6.0" toml = "0.5.9" diff --git a/lib/cli/src/commands/init.rs b/lib/cli/src/commands/init.rs index 584c7764d..16ec43d89 100644 --- a/lib/cli/src/commands/init.rs +++ b/lib/cli/src/commands/init.rs @@ -1,6 +1,7 @@ use anyhow::Context; use cargo_metadata::{CargoOpt, MetadataCommand}; use clap::Parser; +use indexmap::IndexMap; use std::collections::HashMap; use std::path::Path; use std::path::PathBuf; @@ -204,7 +205,7 @@ impl Init { } } - fn get_filesystem_mapping(include: &[String]) -> Option> { + fn get_filesystem_mapping(include: &[String]) -> Option> { if include.is_empty() { return None; } diff --git a/lib/cli/src/commands/publish.rs b/lib/cli/src/commands/publish.rs index 889a39f14..145092bc4 100644 --- a/lib/cli/src/commands/publish.rs +++ b/lib/cli/src/commands/publish.rs @@ -215,7 +215,7 @@ fn construct_tar_gz( } // bundle the package filesystem - let default = std::collections::HashMap::default(); + let default = indexmap::IndexMap::default(); for (_alias, path) in manifest.fs.as_ref().unwrap_or(&default).iter() { let normalized_path = normalize_path(cwd, path); let path_metadata = normalized_path.metadata().map_err(|_| { diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index 2c5fb3868..aa52c4339 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -8,7 +8,6 @@ use crate::suggestions::suggest_function_exports; use crate::warning; use anyhow::{anyhow, Context, Result}; use clap::Parser; -use std::collections::HashMap; use std::ops::Deref; use std::path::PathBuf; #[cfg(feature = "cache")] @@ -124,7 +123,12 @@ impl RunWithPathBuf { #[cfg(feature = "wasi")] { - let default = HashMap::default(); + // See https://github.com/wasmerio/wasmer/issues/3492 - + // we need IndexMap to have a stable ordering for the [fs] mapping, + // otherwise overlapping filesystem mappings might not work + // since we want to control the order of mounting directories from the + // wasmer.toml file + let default = indexmap::IndexMap::default(); let fs = manifest.fs.as_ref().unwrap_or(&default); for (alias, real_dir) in fs.iter() { let real_dir = self_clone.path.join(&real_dir); diff --git a/lib/registry/Cargo.toml b/lib/registry/Cargo.toml index a6608da9d..ce3523aec 100644 --- a/lib/registry/Cargo.toml +++ b/lib/registry/Cargo.toml @@ -20,7 +20,7 @@ serde_json = "1.0.85" url = "2.3.1" thiserror = "1.0.37" toml = "0.5.9" -wasmer-toml = "0.5.0" +wasmer-toml = "0.6.0" tar = "0.4.38" flate2 = "1.0.24" semver = "1.0.14"