{"record":{"id":"b4a914d25e26770c","repo":"zed-industries/zed","slug":"could-not-detect-a-working-directory-in-the-contai","errorCode":null,"errorMessage":"Could not detect a working directory in the container. Set EVAL_CLI_WORKDIR explicitly via --ae EVAL_CLI_WORKDIR=/path/to/repo","messagePattern":"Could not detect a working directory in the container\\. Set EVAL_CLI_WORKDIR explicitly via --ae EVAL_CLI_WORKDIR=/path/to/repo","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"crates/eval_cli/zed_eval/agent_common.py","lineNumber":96,"sourceCode":"            '| head -1 | sed \"s|/.git$||\"'\n        ),\n    )\n    workdir = (result.stdout or \"\").strip()\n    if workdir:\n        return workdir\n\n    result = await exec_as_agent(\n        environment,\n        command=(\n            \"for d in /app /testbed /repo /root /home; do \"\n            '  if [ -d \"$d\" ]; then echo \"$d\"; exit 0; fi; '\n            \"done; pwd\"\n        ),\n    )\n    workdir = (result.stdout or \"\").strip()\n    if workdir:\n        return workdir\n    raise RuntimeError(error_message)\n\n\ndef populate_context_from_result(logs_dir: Path, context: Any, logger: Any) -> None:\n    result_data = None\n    for json_file in logs_dir.rglob(\"result.json\"):\n        try:\n            result_data = json.loads(json_file.read_text())\n            break\n        except (json.JSONDecodeError, OSError):\n            continue\n\n    if result_data is None:\n        logger.warning(\"Could not find or parse result.json from eval-cli\")\n        return\n\n    if result_data.get(\"input_tokens\") is not None:\n        context.n_input_tokens = result_data[\"input_tokens\"]\n    if result_data.get(\"output_tokens\") is not None:","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/eval_cli/zed_eval/agent_common.py#L78-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom eval images built from distroless/scratch; sandboxed runtimes filtering exec output; minimal base images without a conventional app directory.","solutions":["Set the workdir explicitly: `--ae EVAL_CLI_WORKDIR=/path/to/repo`","Bake the repo into the image at one of the probed conventional paths (/app, /testbed, /repo)","Check `docker exec <container> sh -c pwd` returns output; if not, fix the image's shell"],"exampleFix":"# before\nzed-eval run ...   # probe returns nothing → RuntimeError\n\n# after\nzed-eval run ... --ae EVAL_CLI_WORKDIR=/repo","handlingStrategy":"validation","validationCode":"import os\nif not os.environ.get(\"EVAL_CLI_WORKDIR\"):\n    # the image must contain one of /app /testbed /repo /root /home for the probe to succeed\n    print(\"warning: EVAL_CLI_WORKDIR unset; relying on the container probe\")","typeGuard":null,"tryCatchPattern":"try:\n    workdir = await detect_workdir(environment)\nexcept RuntimeError as e:\n    raise SystemExit(f\"{e} — or bake the repo into the image at /app or /testbed\")","preventionTips":["Always pass --ae EVAL_CLI_WORKDIR in automation","Use conventional image layouts (/app, /testbed) for eval containers","Ensure /bin/sh is POSIX in eval images"],"tags":["python","eval-cli","container","docker"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}