From b21fe64093abbcaf3bf326f56f72cbea871586fe Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Sat, 19 Oct 2024 14:59:39 -0700 Subject: [PATCH] chore: update nix crate (#26422) Dedupes nix dependency, since `rustyline` depends on a newer version that what we currently use --- Cargo.lock | 39 ++++++++---------------------------- Cargo.toml | 2 +- ext/fs/Cargo.toml | 2 +- runtime/ops/tty.rs | 3 ++- tests/util/server/Cargo.toml | 2 +- tests/util/server/src/pty.rs | 6 ++++-- 6 files changed, 17 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2032d55ab6..bdcb483e38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -769,7 +769,7 @@ dependencies = [ "http-body-util", "hyper 1.4.1", "hyper-util", - "nix 0.26.2", + "nix", "once_cell", "os_pipe", "pretty_assertions", @@ -1223,7 +1223,7 @@ dependencies = [ "memmem", "monch", "napi_sym", - "nix 0.26.2", + "nix", "node_resolver", "notify", "once_cell", @@ -1438,7 +1438,7 @@ dependencies = [ "deno_unsync", "futures", "libc", - "memoffset 0.9.1", + "memoffset", "parking_lot", "percent-encoding", "pin-project", @@ -1599,7 +1599,7 @@ dependencies = [ "filetime", "junction", "libc", - "nix 0.26.2", + "nix", "rand", "rayon", "serde", @@ -2035,7 +2035,7 @@ dependencies = [ "libc", "log", "netif", - "nix 0.26.2", + "nix", "node_resolver", "notify", "ntapi", @@ -4397,15 +4397,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.9.1" @@ -4563,20 +4554,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "nix" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.7.1", - "pin-utils", - "static_assertions", -] - [[package]] name = "nix" version = "0.27.1" @@ -5776,7 +5753,7 @@ checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49" dependencies = [ "countme", "hashbrown", - "memoffset 0.9.1", + "memoffset", "rustc-hash 1.1.0", "text-size", ] @@ -5984,7 +5961,7 @@ dependencies = [ "libc", "log", "memchr", - "nix 0.27.1", + "nix", "radix_trie", "unicode-segmentation", "unicode-width", @@ -7187,7 +7164,7 @@ dependencies = [ "libc", "lsp-types", "monch", - "nix 0.26.2", + "nix", "once_cell", "os_pipe", "parking_lot", diff --git a/Cargo.toml b/Cargo.toml index e2f439e37b..9f15d03a54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -221,7 +221,7 @@ quote = "1" syn = { version = "2", features = ["full", "extra-traits"] } # unix -nix = "=0.26.2" +nix = "=0.27.1" # windows deps junction = "=0.2.0" diff --git a/ext/fs/Cargo.toml b/ext/fs/Cargo.toml index 313c84fdb6..ab0bf22fd3 100644 --- a/ext/fs/Cargo.toml +++ b/ext/fs/Cargo.toml @@ -31,7 +31,7 @@ serde.workspace = true thiserror.workspace = true [target.'cfg(unix)'.dependencies] -nix.workspace = true +nix = { workspace = true, features = ["user"] } [target.'cfg(windows)'.dependencies] winapi = { workspace = true, features = ["winbase"] } diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs index 5b49e3a248..77e1330b51 100644 --- a/runtime/ops/tty.rs +++ b/runtime/ops/tty.rs @@ -244,7 +244,8 @@ fn op_set_raw( let tty_mode_store = state.borrow::().clone(); let previous_mode = tty_mode_store.get(rid); - let raw_fd = handle_or_fd; + // SAFETY: Nix crate requires value to implement the AsFd trait + let raw_fd = unsafe { std::os::fd::BorrowedFd::borrow_raw(handle_or_fd) }; if is_raw { let mut raw = match previous_mode { diff --git a/tests/util/server/Cargo.toml b/tests/util/server/Cargo.toml index a321501b85..aee7ef0be6 100644 --- a/tests/util/server/Cargo.toml +++ b/tests/util/server/Cargo.toml @@ -35,7 +35,7 @@ lazy-regex.workspace = true libc.workspace = true lsp-types.workspace = true monch.workspace = true -nix.workspace = true +nix = { workspace = true, features = ["fs", "term", "signal"] } once_cell.workspace = true os_pipe.workspace = true parking_lot.workspace = true diff --git a/tests/util/server/src/pty.rs b/tests/util/server/src/pty.rs index 5d8049fee9..8d42fed78b 100644 --- a/tests/util/server/src/pty.rs +++ b/tests/util/server/src/pty.rs @@ -297,10 +297,12 @@ fn setup_pty(fd: i32) { use nix::sys::termios::tcsetattr; use nix::sys::termios::SetArg; - let mut term = tcgetattr(fd).unwrap(); + // SAFETY: Nix crate requires value to implement the AsFd trait + let as_fd = unsafe { std::os::fd::BorrowedFd::borrow_raw(fd) }; + let mut term = tcgetattr(as_fd).unwrap(); // disable cooked mode term.local_flags.remove(termios::LocalFlags::ICANON); - tcsetattr(fd, SetArg::TCSANOW, &term).unwrap(); + tcsetattr(as_fd, SetArg::TCSANOW, &term).unwrap(); // turn on non-blocking mode so we get timeouts let flags = fcntl(fd, FcntlArg::F_GETFL).unwrap();