From 639b56fe70b3dfe3dce4a463f95ed31ba271c400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=BCtt?= Date: Wed, 18 Jan 2023 12:42:14 +0100 Subject: [PATCH 1/3] Update wasmer-toml version --- Cargo.lock | 6 ++++-- lib/cli/Cargo.toml | 3 ++- lib/cli/src/commands/init.rs | 3 ++- lib/cli/src/commands/publish.rs | 2 +- lib/cli/src/commands/run.rs | 3 +-- lib/registry/Cargo.toml | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 742a1f4b0b1..fc933c28285 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 a1960afa947..49d4fad8aa8 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 f6b1fb89e83..2d925e8fa1d 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 889a39f1457..145092bc472 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 e3c968ebd6b..285ade969e6 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -7,7 +7,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; use std::str::FromStr; @@ -121,7 +120,7 @@ impl RunWithPathBuf { #[cfg(feature = "wasi")] { - let default = HashMap::default(); + 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 a6608da9da6..ce3523aec21 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" From 4c770dd1576ee6eaef1481bfaa45ac264196f977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=BCtt?= Date: Thu, 19 Jan 2023 16:35:03 +0100 Subject: [PATCH 2/3] Add comments to explain IndexMap --- lib/cli/src/commands/run.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index 285ade969e6..41705044c11 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -120,6 +120,11 @@ impl RunWithPathBuf { #[cfg(feature = "wasi")] { + // 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() { From a33cb20c3b3ccd13989911d6d7cca1ebb5153b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=BCtt?= Date: Thu, 19 Jan 2023 17:32:20 +0100 Subject: [PATCH 3/3] Fix make lint --- lib/cli/src/commands/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index 41705044c11..0d6bef5a641 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -120,7 +120,7 @@ impl RunWithPathBuf { #[cfg(feature = "wasi")] { - // See https://github.com/wasmerio/wasmer/issues/3492 - + // 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