Skip to content

[apply-patch] Add binary to path - #2626

Closed
dylan-hurd-oai wants to merge 2 commits into
mainfrom
dh--codex-apply-patch-bin
Closed

dylan-hurd-oai wants to merge 2 commits into
mainfrom
dh--codex-apply-patch-bin

Conversation

@dylan-hurd-oai

Copy link
Copy Markdown
Contributor

Summary

Infrequently, certain models will try to use apply_patch as a real bash command. This should decrease dramatically with #2539 and #2576, but I'm opening this as a potential additional fix just in case. Dropping apply_patch as a binary on the PATH will help us reliably catch cases outlined in #2235, without going down the rabbit hole of trying to catch every invocation at the tool call level

Testing

WIP

Comment thread codex-cli/bin/codex.js
if (rgDir) {
additionalDirs.push(rgDir);
}
// 2) Ensure an `apply_patch` helper exists in $CODEX_HOME/<version>/ and add that directory to PATH.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very open to moving this logic into core rust package, curious for thoughts!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presumably this logic will not work when installed via brew?

use std::process::ExitCode;

fn main() -> ExitCode {
// Expect exactly one argument: the full apply_patch payload.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite right: if zero arguments are specified, it is supposed to read from stdin.

Comment thread codex-cli/bin/codex.js
}

const binaryPath = path.join(__dirname, "..", "bin", `codex-${targetTriple}`);
const pkgRoot = path.join(__dirname, "..");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this scheme would work for codex installed via npm, it would not work for someone who installs via brew or someone who downloads from GitHub Releases.

Building this into https://github.com/openai/codex/blob/main/codex-rs/arg0/src/lib.rs would solve this problem.

@bolinfest

Copy link
Copy Markdown
Collaborator

New approach in #2646.

@github-actions github-actions Bot locked and limited conversation to collaborators Aug 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants