mirror of
https://github.com/openai/codex.git
synced 2026-05-02 12:21:26 +03:00
copy current exe to CODEX_HOME/.sandbox-bin for apply_patch (#13669)
We do this for codex-command-runner.exe as well for the same reason. Windows sandbox users cannot execute binaries in the WindowsApp/ installed directory for the Codex App. This causes apply-patch to fail because it tries to execute codex.exe as the sandbox user.
This commit is contained in:
@@ -88,6 +88,34 @@ pub(crate) fn resolve_helper_for_launch(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_current_exe_for_launch(
|
||||
codex_home: &Path,
|
||||
fallback_executable: &str,
|
||||
) -> PathBuf {
|
||||
let source = match std::env::current_exe() {
|
||||
Ok(path) => path,
|
||||
Err(_) => return PathBuf::from(fallback_executable),
|
||||
};
|
||||
let Some(file_name) = source.file_name() else {
|
||||
return source;
|
||||
};
|
||||
let destination = helper_bin_dir(codex_home).join(file_name);
|
||||
match copy_from_source_if_needed(&source, &destination) {
|
||||
Ok(_) => destination,
|
||||
Err(err) => {
|
||||
let sandbox_log_dir = crate::sandbox_dir(codex_home);
|
||||
log_note(
|
||||
&format!(
|
||||
"helper copy failed for current executable: {err:#}; falling back to legacy path {}",
|
||||
source.display()
|
||||
),
|
||||
Some(&sandbox_log_dir),
|
||||
);
|
||||
source
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn copy_helper_if_needed(
|
||||
kind: HelperExecutable,
|
||||
codex_home: &Path,
|
||||
@@ -349,3 +377,4 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user