Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Fix Bazel cargo_bin runfiles paths (#19468)

Curtis 'Fjord' Hawthornecf02e9c05276
diff --git a/codex-rs/utils/cargo-bin/src/lib.rs b/codex-rs/utils/cargo-bin/src/lib.rs
index 6517a77c94..2cb25a6b17 100644
--- a/codex-rs/utils/cargo-bin/src/lib.rs
+++ b/codex-rs/utils/cargo-bin/src/lib.rs
@@ -91,10 +91,15 @@ fn resolve_bin_from_env(key: &str, value: OsString) -> Result<PathBuf, CargoBinE
let runfiles = runfiles::Runfiles::create().map_err(|err| CargoBinError::CurrentExe {
source: std::io::Error::other(err),
})?;
- if let Some(resolved) = runfiles::rlocation!(runfiles, &raw)
- && resolved.exists()
- {
- return Ok(resolved);
+ if let Some(mut resolved) = runfiles::rlocation!(runfiles, &raw) {
+ if !resolved.is_absolute() {
+ resolved = std::env::current_dir()
+ .map_err(|source| CargoBinError::CurrentDir { source })?
+ .join(resolved);
+ }
+ if resolved.exists() {
+ return Ok(resolved);
+ }
}
} else if raw.is_absolute() && raw.exists() {
return Ok(raw);