diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs index a7629a107f7..1b72339a4ab 100644 --- a/codex-rs/exec/src/lib.rs +++ b/codex-rs/exec/src/lib.rs @@ -296,7 +296,12 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option) -> any let default_effort = config.model_reasoning_effort; let default_summary = config.model_reasoning_summary; - if !skip_git_repo_check && get_git_repo_root(&default_cwd).is_none() { + // When --yolo (dangerously_bypass_approvals_and_sandbox) is set, also skip the git repo check + // since the user is explicitly running in an externally sandboxed environment. + if !skip_git_repo_check + && !dangerously_bypass_approvals_and_sandbox + && get_git_repo_root(&default_cwd).is_none() + { eprintln!("Not inside a trusted directory and --skip-git-repo-check was not specified."); std::process::exit(1); }