zed-industries/zed · error · RuntimeError

Could not detect a working directory in the container. Set E

Error message

Could not detect a working directory in the container. Set EVAL_CLI_WORKDIR explicitly via --ae EVAL_CLI_WORKDIR=/path/to/repo

What it means

agent_common probes the container for a working directory by testing /app, /testbed, /repo, /root, /home in order and falling back to `pwd`; if the exec yields no usable stdout, the RuntimeError names the escape hatch: set EVAL_CLI_WORKDIR explicitly via --ae. Since `pwd` always prints on a POSIX shell, an empty result usually means the exec misbehaved or the image's shell isn't POSIX.

Source

Thrown at crates/eval_cli/zed_eval/agent_common.py:96

            '| head -1 | sed "s|/.git$||"'
        ),
    )
    workdir = (result.stdout or "").strip()
    if workdir:
        return workdir

    result = await exec_as_agent(
        environment,
        command=(
            "for d in /app /testbed /repo /root /home; do "
            '  if [ -d "$d" ]; then echo "$d"; exit 0; fi; '
            "done; pwd"
        ),
    )
    workdir = (result.stdout or "").strip()
    if workdir:
        return workdir
    raise RuntimeError(error_message)


def populate_context_from_result(logs_dir: Path, context: Any, logger: Any) -> None:
    result_data = None
    for json_file in logs_dir.rglob("result.json"):
        try:
            result_data = json.loads(json_file.read_text())
            break
        except (json.JSONDecodeError, OSError):
            continue

    if result_data is None:
        logger.warning("Could not find or parse result.json from eval-cli")
        return

    if result_data.get("input_tokens") is not None:
        context.n_input_tokens = result_data["input_tokens"]
    if result_data.get("output_tokens") is not None:

View on GitHub (pinned to bc538def45)

Solutions

  1. Set the workdir explicitly: `--ae EVAL_CLI_WORKDIR=/path/to/repo`
  2. Bake the repo into the image at one of the probed conventional paths (/app, /testbed, /repo)
  3. Check `docker exec <container> sh -c pwd` returns output; if not, fix the image's shell

Example fix

# before
zed-eval run ...   # probe returns nothing → RuntimeError

# after
zed-eval run ... --ae EVAL_CLI_WORKDIR=/repo
Defensive patterns

Strategy: validation

Validate before calling

import os
if not os.environ.get("EVAL_CLI_WORKDIR"):
    # the image must contain one of /app /testbed /repo /root /home for the probe to succeed
    print("warning: EVAL_CLI_WORKDIR unset; relying on the container probe")

Try / catch

try:
    workdir = await detect_workdir(environment)
except RuntimeError as e:
    raise SystemExit(f"{e} — or bake the repo into the image at /app or /testbed")

Prevention

When it happens

Trigger: Containers whose /bin/sh is missing or non-POSIX (distroless, scratch, some nix builds); an exec layer that swallows stdout; restricted busybox or fish as the default shell.

Common situations: Custom eval images built from distroless/scratch; sandboxed runtimes filtering exec output; minimal base images without a conventional app directory.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/b4a914d25e26770c. Report an issue: GitHub.