codex_exec_server/
runtime_paths.rs1use std::path::PathBuf;
2
3use codex_utils_absolute_path::AbsolutePathBuf;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct ExecServerRuntimePaths {
8 pub codex_self_exe: AbsolutePathBuf,
10 pub codex_linux_sandbox_exe: Option<AbsolutePathBuf>,
13}
14
15impl ExecServerRuntimePaths {
16 pub fn from_optional_paths(
17 codex_self_exe: Option<PathBuf>,
18 codex_linux_sandbox_exe: Option<PathBuf>,
19 ) -> std::io::Result<Self> {
20 let codex_self_exe = codex_self_exe.ok_or_else(|| {
21 std::io::Error::new(
22 std::io::ErrorKind::InvalidInput,
23 "Codex executable path is not configured",
24 )
25 })?;
26 Self::new(codex_self_exe, codex_linux_sandbox_exe)
27 }
28
29 pub fn new(
30 codex_self_exe: PathBuf,
31 codex_linux_sandbox_exe: Option<PathBuf>,
32 ) -> std::io::Result<Self> {
33 Ok(Self {
34 codex_self_exe: absolute_path(codex_self_exe)?,
35 codex_linux_sandbox_exe: codex_linux_sandbox_exe.map(absolute_path).transpose()?,
36 })
37 }
38}
39
40fn absolute_path(path: PathBuf) -> std::io::Result<AbsolutePathBuf> {
41 AbsolutePathBuf::from_absolute_path(path.as_path())
42 .map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))
43}