From 16c0053d68c7dc263d1043b9fa9709f7243c2607 Mon Sep 17 00:00:00 2001 From: Karamelmar Date: Mon, 9 Mar 2026 13:43:30 +0100 Subject: [PATCH] Fix: bin/claude fallback workdir when cwd is outside mounted project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When CS Core's A2A server process (cwd = ~/.context-studio/core) runs 'claude --version' to check requirements, bin/claude passed --workdir $PWD to podman exec. But the core dir is not mounted in the container, so podman fails → check reports claude-code missing → server exits code 1. Fix: if $PWD is not under $PROJECT_DIR (the only mounted path), fall back to $PROJECT_DIR as the container workdir. Co-Authored-By: Claude Sonnet 4.6 --- lib/container.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/container.sh b/lib/container.sh index af3882c..224b1c5 100644 --- a/lib/container.sh +++ b/lib/container.sh @@ -17,6 +17,7 @@ generate_container_scripts() { # Claude Code wrapper — runs claude inside the agents container. # CS Core on the host calls this instead of the real claude binary. CONTAINER_NAME="${container_name}" +PROJECT_DIR="${project_dir}" RUNTIME="\$(command -v podman || command -v docker || true)" if [[ -z "\$RUNTIME" ]]; then @@ -30,11 +31,21 @@ if ! "\$RUNTIME" container inspect "\$CONTAINER_NAME" --format '{{.State.Running exit 1 fi +# Use PWD as workdir only if it is inside the mounted project tree. +# When CS Core's server process calls claude --version its cwd is the +# core directory (~/.context-studio/core) which is NOT mounted, causing +# podman exec --workdir to fail. Fall back to PROJECT_DIR in that case. +if [[ "\$PWD" == "\$PROJECT_DIR"* ]]; then + WORKDIR="\$PWD" +else + WORKDIR="\$PROJECT_DIR" +fi + # Pass through TTY if available, relay working directory into container if [ -t 0 ]; then - exec "\$RUNTIME" exec -it --workdir "\$PWD" "\$CONTAINER_NAME" claude "\$@" + exec "\$RUNTIME" exec -it --workdir "\$WORKDIR" "\$CONTAINER_NAME" claude "\$@" else - exec "\$RUNTIME" exec -i --workdir "\$PWD" "\$CONTAINER_NAME" claude "\$@" + exec "\$RUNTIME" exec -i --workdir "\$WORKDIR" "\$CONTAINER_NAME" claude "\$@" fi WRAPPER chmod +x "$project_dir/bin/claude"