From f172e4286978041a8115b132c0019c211ddaddea Mon Sep 17 00:00:00 2001 From: YizhePKU Date: Fri, 18 Oct 2024 01:12:45 +0800 Subject: [PATCH] Reduce duplicate dependencies on the `windows` crate (#14105) Nushell currently depends on three different versions of the `windows` crate: `0.44.0`, `0.52.0`, and `0.54.0`. This PR bumps several dependencies so that the `nu` binary only depends on `0.56.0`. On my machine, this PR makes `cargo build` about 10% faster. The polars plugin still uses its own version of the `windows` crate though, which is not ideal. We'll need to bump the `polars` crate to fix that, but it breaks a lot of our code. (`polars 1.0` release anyone?) --- Cargo.lock | 166 +++++++++++----------------- Cargo.toml | 6 +- crates/nu-command/src/debug/info.rs | 6 +- 3 files changed, 69 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6f1e35bd1..424914e606 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2611,15 +2611,6 @@ dependencies = [ "libc", ] -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - [[package]] name = "markup5ever" version = "0.12.1" @@ -3025,7 +3016,7 @@ dependencies = [ "percent-encoding", "reedline", "rstest", - "sysinfo", + "sysinfo 0.32.0", "tempfile", "unicode-segmentation", "uuid", @@ -3187,7 +3178,7 @@ dependencies = [ "serde_urlencoded", "serde_yaml", "sha2", - "sysinfo", + "sysinfo 0.32.0", "tabled", "tempfile", "terminal_size", @@ -3210,7 +3201,7 @@ dependencies = [ "v_htmlescape", "wax", "which", - "windows 0.54.0", + "windows 0.56.0", "winreg", ] @@ -3356,7 +3347,7 @@ dependencies = [ "rmp-serde", "serde", "serde_json", - "windows 0.54.0", + "windows 0.56.0", ] [[package]] @@ -3372,7 +3363,7 @@ dependencies = [ "nu-utils", "serde", "typetag", - "windows 0.54.0", + "windows 0.56.0", ] [[package]] @@ -3477,8 +3468,8 @@ dependencies = [ "ntapi", "once_cell", "procfs", - "sysinfo", - "windows 0.54.0", + "sysinfo 0.32.0", + "windows 0.56.0", ] [[package]] @@ -3761,15 +3752,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", -] - [[package]] name = "objc-sys" version = "0.3.5" @@ -4729,7 +4711,7 @@ dependencies = [ "rayon", "smartstring", "stacker", - "sysinfo", + "sysinfo 0.30.13", "version_check", ] @@ -6115,10 +6097,23 @@ dependencies = [ "libc", "ntapi", "once_cell", - "rayon", "windows 0.52.0", ] +[[package]] +name = "sysinfo" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ae3f4f7d64646c46c4cae4e3f01d1c5d255c7406fdd7c7f999a94e488791" +dependencies = [ + "core-foundation-sys", + "libc", + "memchr", + "ntapi", + "rayon", + "windows 0.56.0", +] + [[package]] name = "tabled" version = "0.16.0" @@ -6442,18 +6437,19 @@ dependencies = [ [[package]] name = "trash" -version = "3.3.1" +version = "5.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c658458d46d9d5a153a3b5cdd88d8579ad50d4fb85d53961e4526c8fc7c55a57" +checksum = "33caf2a9be1812a263a4bfce74d2de225fcde12ee7b77001361abd2b34ffdcc4" dependencies = [ "chrono", "libc", "log", - "objc", + "objc2", + "objc2-foundation", "once_cell", "scopeguard", - "url", - "windows 0.44.0", + "urlencoding", + "windows 0.56.0", ] [[package]] @@ -6642,6 +6638,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf-8" version = "0.7.6" @@ -7083,15 +7085,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows" version = "0.52.0" @@ -7104,11 +7097,11 @@ dependencies = [ [[package]] name = "windows" -version = "0.54.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" dependencies = [ - "windows-core 0.54.0", + "windows-core 0.56.0", "windows-targets 0.52.6", ] @@ -7123,14 +7116,38 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.54.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" dependencies = [ + "windows-implement", + "windows-interface", "windows-result", "windows-targets 0.52.6", ] +[[package]] +name = "windows-implement" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.75", +] + +[[package]] +name = "windows-interface" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.75", +] + [[package]] name = "windows-result" version = "0.1.2" @@ -7180,21 +7197,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -7226,12 +7228,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.6", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -7250,12 +7246,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -7274,12 +7264,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -7304,12 +7288,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -7328,12 +7306,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -7346,12 +7318,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -7370,12 +7336,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" diff --git a/Cargo.toml b/Cargo.toml index 9e758041a6..f1052e229b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,13 +153,13 @@ serde_yaml = "0.9" sha2 = "0.10" strip-ansi-escapes = "0.2.0" syn = "2.0" -sysinfo = "0.30" +sysinfo = "0.32" tabled = { version = "0.16.0", default-features = false } tempfile = "3.13" terminal_size = "0.3" titlecase = "2.0" toml = "0.8" -trash = "3.3" +trash = "5.1" umask = "2.1" unicode-segmentation = "1.12" unicode-width = "0.1" @@ -176,7 +176,7 @@ uuid = "1.10.0" v_htmlescape = "0.15.0" wax = "0.6" which = "6.0.0" -windows = "0.54" +windows = "0.56" windows-sys = "0.48" winreg = "0.52" diff --git a/crates/nu-command/src/debug/info.rs b/crates/nu-command/src/debug/info.rs index da4689738e..2a680ae20d 100644 --- a/crates/nu-command/src/debug/info.rs +++ b/crates/nu-command/src/debug/info.rs @@ -101,7 +101,7 @@ fn all_columns(span: Span) -> Value { let environment = { let mut env_rec = Record::new(); for val in p.environ() { - if let Some((key, value)) = val.split_once('=') { + if let Some((key, value)) = val.to_string_lossy().split_once('=') { let is_env_var_a_list = { { #[cfg(target_family = "windows")] @@ -146,8 +146,8 @@ fn all_columns(span: Span) -> Value { "root" => root, "cwd" => cwd, "exe_path" => exe_path, - "command" => Value::string(p.cmd().join(" "), span), - "name" => Value::string(p.name(), span), + "command" => Value::string(p.cmd().join(std::ffi::OsStr::new(" ")).to_string_lossy(), span), + "name" => Value::string(p.name().to_string_lossy(), span), "environment" => environment, }, span,