From 1f690619563bc6734bf6dcb2bcb0da9b4005d2a3 Mon Sep 17 00:00:00 2001 From: Hare Date: Tue, 7 Jul 2026 03:27:12 +0900 Subject: [PATCH] fix: normalize runtime workspace bootstrap --- .yoi/workspace-backend.local.toml | 12 ++++++++++-- crates/worker-runtime/src/main.rs | 32 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.yoi/workspace-backend.local.toml b/.yoi/workspace-backend.local.toml index 1c25e850..76a1fcb4 100644 --- a/.yoi/workspace-backend.local.toml +++ b/.yoi/workspace-backend.local.toml @@ -1,5 +1,8 @@ -# Dogfood Workspace Backend configuration. -# Repository URI values are resolved from this workspace config root. +[server] + +[data] + +[limits] [[repositories]] id = "main" @@ -7,3 +10,8 @@ provider = "git" uri = "." display_name = "Yoi" default_selector = "HEAD" + +[[runtimes.remote]] +id = "arc" +endpoint = "http://127.0.0.1:38800" +display_name = "arc" diff --git a/crates/worker-runtime/src/main.rs b/crates/worker-runtime/src/main.rs index 4b1e49e6..b589768f 100644 --- a/crates/worker-runtime/src/main.rs +++ b/crates/worker-runtime/src/main.rs @@ -215,12 +215,33 @@ where } apply_store_selection(&mut config.http, store)?; + config.workspace_root = normalize_workspace_path(config.workspace_root)?; if config.cwd.as_os_str().is_empty() { config.cwd = config.workspace_root.clone(); + } else { + config.cwd = normalize_child_path(&config.workspace_root, config.cwd); } Ok(Some(config)) } +fn normalize_workspace_path(path: PathBuf) -> Result { + let absolute = if path.is_absolute() { + path + } else { + env::current_dir()?.join(path) + }; + Ok(absolute.canonicalize().unwrap_or(absolute)) +} + +fn normalize_child_path(base: &std::path::Path, path: PathBuf) -> PathBuf { + if path.is_absolute() { + path.canonicalize().unwrap_or(path) + } else { + let absolute = base.join(path); + absolute.canonicalize().unwrap_or(absolute) + } +} + fn split_flag_value(arg: String) -> Result<(String, Option), ProcessError> { if !arg.starts_with('-') { return Err(ProcessError::usage(format!( @@ -395,6 +416,17 @@ mod tests { ); } + #[test] + fn normalizes_relative_workspace_for_worker_spawn() { + let current_dir = env::current_dir().unwrap().canonicalize().unwrap(); + let config = parse_args(["--workspace", ".", "--cwd", "."]) + .unwrap() + .unwrap(); + + assert_eq!(config.workspace_root, current_dir); + assert_eq!(config.cwd, current_dir); + } + #[test] fn parses_memory_runtime_process_config() { let config = parse_args([