Lightweight coding agent that runs in your terminal
Rust
fix: remove dependency on expanduser crate (#667)
Michael Bolinebd2ae4abdef
diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lockindex 1f91c0072b..f866ed6beb 100644--- a/codex-rs/Cargo.lock+++ b/codex-rs/Cargo.lock@@ -171,18 +171,6 @@ version = "1.0.98"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"-[[package]]-name = "arrayref"-version = "0.3.9"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"--[[package]]-name = "arrayvec"-version = "0.5.2"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"-[[package]]name = "ascii-canvas"version = "3.0.0"@@ -268,12 +256,6 @@ dependencies = ["rustc-demangle",]-[[package]]-name = "base64"-version = "0.13.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"-[[package]]name = "base64"version = "0.21.7"@@ -319,17 +301,6 @@ version = "2.9.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"-[[package]]-name = "blake2b_simd"-version = "0.5.11"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"-dependencies = [- "arrayref",- "arrayvec",- "constant_time_eq",-]-[[package]]name = "bstr"version = "1.12.0"@@ -524,10 +495,9 @@ dependencies = ["bytes","clap","codex-apply-patch",- "dirs 6.0.0",+ "dirs","env-flags","eventsource-stream",- "expanduser","fs-err","futures","landlock",@@ -684,12 +654,6 @@ dependencies = ["crossbeam-utils",]-[[package]]-name = "constant_time_eq"-version = "0.1.5"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"-[[package]]name = "convert_case"version = "0.6.0"@@ -890,17 +854,6 @@ version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"-[[package]]-name = "dirs"-version = "1.0.5"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"-dependencies = [- "libc",- "redox_users 0.3.5",- "winapi",-]-[[package]]name = "dirs"version = "6.0.0"@@ -1132,17 +1085,6 @@ dependencies = ["pin-project-lite",]-[[package]]-name = "expanduser"-version = "1.2.2"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "14e0b79235da57db6b6c2beed9af6e5de867d63a973ae3e91910ddc33ba40bc0"-dependencies = [- "dirs 1.0.5",- "lazy_static",- "pwd",-]-[[package]]name = "eyre"version = "0.6.12"@@ -1328,17 +1270,6 @@ dependencies = ["byteorder",]-[[package]]-name = "getrandom"-version = "0.1.16"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"-dependencies = [- "cfg-if",- "libc",- "wasi 0.9.0+wasi-snapshot-preview1",-]-[[package]]name = "getrandom"version = "0.2.16"@@ -2340,7 +2271,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"dependencies = ["cfg-if","libc",- "redox_syscall 0.5.11",+ "redox_syscall","smallvec","windows-targets 0.52.6",]@@ -2508,16 +2439,6 @@ dependencies = ["unicode-ident",]-[[package]]-name = "pwd"-version = "1.4.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "72c71c0c79b9701efe4e1e4b563b2016dd4ee789eb99badcb09d61ac4b92e4a2"-dependencies = [- "libc",- "thiserror 1.0.69",-]-[[package]]name = "quote"version = "1.0.40"@@ -2593,12 +2514,6 @@ dependencies = ["unicode-width 0.2.0",]-[[package]]-name = "redox_syscall"-version = "0.1.57"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"-[[package]]name = "redox_syscall"version = "0.5.11"@@ -2608,17 +2523,6 @@ dependencies = ["bitflags 2.9.0",]-[[package]]-name = "redox_users"-version = "0.3.5"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"-dependencies = [- "getrandom 0.1.16",- "redox_syscall 0.1.57",- "rust-argon2",-]-[[package]]name = "redox_users"version = "0.4.6"@@ -2765,18 +2669,6 @@ dependencies = ["windows-sys 0.52.0",]-[[package]]-name = "rust-argon2"-version = "0.8.3"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"-dependencies = [- "base64 0.13.1",- "blake2b_simd",- "constant_time_eq",- "crossbeam-utils",-]-[[package]]name = "rustc-demangle"version = "0.1.24"@@ -3908,12 +3800,6 @@ dependencies = ["try-lock",]-[[package]]-name = "wasi"-version = "0.9.0+wasi-snapshot-preview1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"-[[package]]name = "wasi"version = "0.11.0+wasi-snapshot-preview1"diff --git a/codex-rs/core/Cargo.toml b/codex-rs/core/Cargo.tomlindex 778362d275..daadec7294 100644--- a/codex-rs/core/Cargo.toml+++ b/codex-rs/core/Cargo.toml@@ -17,7 +17,6 @@ codex-apply-patch = { path = "../apply-patch" }dirs = "6"env-flags = "0.1.1"eventsource-stream = "0.2.3"-expanduser = "1.2.2"fs-err = "3.1.0"futures = "0.3"mime_guess = "2.0"diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rsindex a23c11cde5..cfeb7e401f 100644--- a/codex-rs/core/src/codex.rs+++ b/codex-rs/core/src/codex.rs@@ -1,6 +1,7 @@use std::collections::HashMap;use std::collections::HashSet;use std::io::Write;+use std::path::Path;use std::path::PathBuf;use std::process::Command;use std::process::Stdio;@@ -15,7 +16,6 @@ use codex_apply_patch::print_summary;use codex_apply_patch::AffectedPaths;use codex_apply_patch::ApplyPatchFileChange;use codex_apply_patch::MaybeApplyPatchVerified;-use expanduser::expanduser;use fs_err as fs;use futures::prelude::*;use serde::Serialize;@@ -113,23 +113,15 @@ impl CodexBuilder {})}- pub fn record_submissions(mut self, path: impl AsRef<str>) -> Self {- let path = match expanduser(path.as_ref()) {- Ok(path) => path,- Err(_) => PathBuf::from(path.as_ref()),- };- debug!("Recording submissions to {}", path.display());- self.record_submissions = Some(path);+ pub fn record_submissions(mut self, path: impl AsRef<Path>) -> Self {+ debug!("Recording submissions to {:?}", path.as_ref());+ self.record_submissions = Some(path.as_ref().to_path_buf());self}- pub fn record_events(mut self, path: impl AsRef<str>) -> Self {- let path = match expanduser(path.as_ref()) {- Ok(path) => path,- Err(_) => PathBuf::from(path.as_ref()),- };- debug!("Recording events to {}", path.display());- self.record_events = Some(path);+ pub fn record_events(mut self, path: impl AsRef<Path>) -> Self {+ debug!("Recording events to {:?}", path.as_ref());+ self.record_events = Some(path.as_ref().to_path_buf());self}}diff --git a/codex-rs/repl/src/cli.rs b/codex-rs/repl/src/cli.rsindex 4de42a76de..ec6c652519 100644--- a/codex-rs/repl/src/cli.rs+++ b/codex-rs/repl/src/cli.rs@@ -56,9 +56,9 @@ pub struct Cli {/// Record submissions into file as JSON#[arg(short = 'S', long)]- pub record_submissions: Option<String>,+ pub record_submissions: Option<PathBuf>,/// Record events into file as JSON#[arg(short = 'E', long)]- pub record_events: Option<String>,+ pub record_events: Option<PathBuf>,}