Files
codex/codex-rs/utils/cargo-bin
Curtis 'Fjord' Hawthorne cf02e9c052 Fix Bazel cargo_bin runfiles paths (#19468)
## Summary

Fix a Bazel-only path resolution bug in
`codex_utils_cargo_bin::cargo_bin`.

Under Bazel runfiles, `rlocation` can return a relative `bazel-out/...`
path even though `cargo_bin()` documents that it returns an absolute
path. That can break callers that store the returned binary path and
later spawn it after changing cwd, because the relative path is resolved
from the wrong directory.

This patch absolutizes the runfiles-resolved path before returning it.
2026-04-24 17:47:31 -07:00
..

codex-utils-cargo-bin runfiles strategy

We disable the directory-based runfiles strategy and rely on the manifest strategy across all platforms. This avoids Windows path length issues and keeps behavior consistent in local and remote builds on all platforms. Bazel sets RUNFILES_MANIFEST_FILE, and the codex-utils-cargo-bin helpers use the runfiles crate to resolve runfiles via that manifest.

Function behavior:

  • cargo_bin: reads CARGO_BIN_EXE_* environment variables (set by Cargo or Bazel) and resolves them via the runfiles manifest when RUNFILES_MANIFEST_FILE is present. When not under runfiles, it only accepts absolute paths from CARGO_BIN_EXE_* and returns an error otherwise.
  • find_resource!: used by tests to locate fixtures. It chooses the Bazel runfiles resolution path when RUNFILES_MANIFEST_FILE is set, otherwise it falls back to a CARGO_MANIFEST_DIR-relative path for Cargo runs.

Background: