From 0ac886bf95520ed6fc8371ff13e85d1c816738c6 Mon Sep 17 00:00:00 2001 From: "A. F. Dudley" Date: Fri, 20 Mar 2026 15:06:38 +0000 Subject: [PATCH] fix: chdir to repo root before create_operation in restart The spec's "stack:" value is a relative path that must resolve from the repo root. stack_is_external() checks Path(stack).exists() from cwd, which fails when cwd isn't the repo root. Co-Authored-By: Claude Opus 4.6 (1M context) --- stack_orchestrator/deploy/deployment.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stack_orchestrator/deploy/deployment.py b/stack_orchestrator/deploy/deployment.py index 9eb011e6..47606d5f 100644 --- a/stack_orchestrator/deploy/deployment.py +++ b/stack_orchestrator/deploy/deployment.py @@ -397,7 +397,14 @@ def restart(ctx, stack_path, spec_file, config_file, force, expected_ip, image): print("\n[2/4] Hostname unchanged, skipping DNS verification") # Step 3: Sync deployment directory with spec + # The spec's "stack:" value is often a relative path (e.g. + # "stack-orchestrator/stacks/dumpster") that must resolve from the + # repo root. Change cwd so stack_is_external() sees it correctly. print("\n[3/4] Syncing deployment directory...") + import os + + prev_cwd = os.getcwd() + os.chdir(repo_root) deploy_ctx = make_deploy_context(ctx) create_operation( deployment_command_context=deploy_ctx, @@ -407,6 +414,7 @@ def restart(ctx, stack_path, spec_file, config_file, force, expected_ip, image): network_dir=None, initial_peers=None, ) + os.chdir(prev_cwd) # Reload deployment context with updated spec deployment_context.init(deployment_context.deployment_dir)