Fix: bin/claude fallback workdir when cwd is outside mounted project
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 <noreply@anthropic.com>
This commit is contained in:
parent
0028ef4262
commit
16c0053d68
1 changed files with 13 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ generate_container_scripts() {
|
||||||
# Claude Code wrapper — runs claude inside the agents container.
|
# Claude Code wrapper — runs claude inside the agents container.
|
||||||
# CS Core on the host calls this instead of the real claude binary.
|
# CS Core on the host calls this instead of the real claude binary.
|
||||||
CONTAINER_NAME="${container_name}"
|
CONTAINER_NAME="${container_name}"
|
||||||
|
PROJECT_DIR="${project_dir}"
|
||||||
RUNTIME="\$(command -v podman || command -v docker || true)"
|
RUNTIME="\$(command -v podman || command -v docker || true)"
|
||||||
|
|
||||||
if [[ -z "\$RUNTIME" ]]; then
|
if [[ -z "\$RUNTIME" ]]; then
|
||||||
|
|
@ -30,11 +31,21 @@ if ! "\$RUNTIME" container inspect "\$CONTAINER_NAME" --format '{{.State.Running
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# Pass through TTY if available, relay working directory into container
|
||||||
if [ -t 0 ]; then
|
if [ -t 0 ]; then
|
||||||
exec "\$RUNTIME" exec -it --workdir "\$PWD" "\$CONTAINER_NAME" claude "\$@"
|
exec "\$RUNTIME" exec -it --workdir "\$WORKDIR" "\$CONTAINER_NAME" claude "\$@"
|
||||||
else
|
else
|
||||||
exec "\$RUNTIME" exec -i --workdir "\$PWD" "\$CONTAINER_NAME" claude "\$@"
|
exec "\$RUNTIME" exec -i --workdir "\$WORKDIR" "\$CONTAINER_NAME" claude "\$@"
|
||||||
fi
|
fi
|
||||||
WRAPPER
|
WRAPPER
|
||||||
chmod +x "$project_dir/bin/claude"
|
chmod +x "$project_dir/bin/claude"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue