Conversation
This was referenced Jul 28, 2025
This was referenced Jul 28, 2025
pakrym-oai
approved these changes
Jul 28, 2025
bolinfest
added a commit
that referenced
this pull request
Jul 28, 2025
Apparently `std::env::args()` will panic during iteration if any argument to the process is not valid Unicode: https://doc.rust-lang.org/std/env/fn.args.html Let's avoid the risk and just go with `std::env::args_os()`. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1698). * #1705 * #1703 * #1702 * __->__ #1698 * #1697
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces some special behavior to the CLIs that are using the
codex-arg0crate where ifarg1is--codex-run-as-apply-patch, then it will run as ifapply_patch arg2were invoked. This is important because it means we can do things like:which gives us a way to run
apply_patchwhile ensuring it adheres to the sandbox the user specified.While it would be nice to use the
arg0trick like we are currently doing forcodex-linux-sandbox, there is no way to specify thearg0for the underlying command when running under/usr/bin/sandbox-exec, so it will not work for us in this case.Admittedly, we could have also supported this via a custom environment variable (e.g.,
CODEX_ARG0), but since environment variables are inherited by child processes, that seemed like a potentially leakier abstraction.This change, as well as our existing reliance on checking
arg0, place additional requirements on those who includecodex-core. ItsREADME.mdhas been updated to reflect this.While we could have just added an
apply-patchsubcommand to thecodexmultitool CLI, that would not be sufficient for the standalonecodex-execCLI, which is something that we distribute as part of our GitHub releases for those who know they will not be using the TUI and therefore prefer to use a slightly smaller executable:https://github.com/openai/codex/releases/tag/rust-v0.10.0
To that end, this PR adds an integration test to ensure that the
--codex-run-as-apply-patchoption works with the standalonecodex-execCLI.Stack created with Sapling. Best reviewed with ReviewStack.