fix: remove dependency on expanduser crate (#667)

In putting up https://github.com/openai/codex/pull/665, I discovered
that the `expanduser` crate does not compile on Windows. Looking into
it, we do not seem to need it because we were only using it with a value
that was passed in via a command-line flag, so the shell expands `~` for
us before we see it, anyway. (I changed the type in `Cli` from `String`
to `PathBuf`, to boot.)

If we do need this sort of functionality in the future,
https://docs.rs/shellexpand/latest/shellexpand/fn.tilde.html seems
promising.
This commit is contained in:
Michael Bolin
2025-04-25 14:20:21 -07:00
committed by GitHub
parent 9c3ebac3b7
commit ebd2ae4abd
4 changed files with 11 additions and 134 deletions

View File

@@ -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
}
}