Skip to content

[Bug] Desktop app does not inherit user env vars into Bash subprocess (BASH_DEFAULT_TIMEOUT_MS etc.) #163

Description

@Krutov-mcp

Problem

ZCode desktop (Windows 11 Pro, v3.3.6) does not pass user environment variables into Bash subprocesses spawned by the Bash tool. Only ZCODE_* variables explicitly injected by ZCode are visible. This breaks documented Claude Code env vars like BASH_DEFAULT_TIMEOUT_MS, CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR, API_TIMEOUT_MS, etc.

This appears to be the same root cause as anthropics/claude-code#42203 ("Desktop app ignores env.PATH from settings.json — sandbox overrides").

Reproduction

  1. Set a user env var on Windows:
    setx BASH_DEFAULT_TIMEOUT_MS "300000"
    setx ZCODE_TEST_ENV_VAR "hello-from-setx"
  2. Restart ZCode desktop.
  3. Open a chat, ask the agent: "print all env vars containing ZCODE_TEST or BASH_DEFAULT".
  4. The agent runs env | grep ... via Bash tool.

Expected

Both ZCODE_TEST_ENV_VAR=hello-from-setx and BASH_DEFAULT_TIMEOUT_MS=300000 should be visible in the subprocess.

Actual

ZCODE_APP_VERSION=3.3.6
ZCODE_RUNTIME_ENV=production
ZCODE_WINDOWS_APP_INSTALL_DIR=...
ZCODE_RG_BINARY=...
ZCODE_PROCESS_LABEL=local-1
ZCODE_BASE_URL=https://zcode.z.ai
ZCODE_ENV=production

No BASH_DEFAULT_TIMEOUT_MS, no ZCODE_TEST_ENV_VAR, no user-set vars. Only ZCode-injected ones appear.

Also tried: setting an env block in ~/.zcode/cli/config.json:

{ "env": { "BASH_DEFAULT_TIMEOUT_MS": "300000" } }

Same result — the var is not visible in subprocess.

Note: env field inside MCP servers DOES work

For comparison, the env field inside an MCP server config is honored correctly:

{
  "mcp": { "servers": { "excel": {
    "env": { "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000" }
  } } }
}

This works — the var reaches the MCP server process. The issue is specifically with the Bash/Read/Edit/Write built-in tools.

Impact

  • Documented Claude Code env vars (BASH_DEFAULT_TIMEOUT_MS, API_TIMEOUT_MS, CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR, etc.) are non-functional in ZCode desktop.
  • Users relying on these for long-running test suites / deploy scripts get silent breakage with default 2-min timeout.

Environment

  • ZCode 3.3.6, Windows 11 Pro (10.0.26200).
  • GLM-5.2 via Z.ai Coding Plan (Max).
  • PowerShell setx confirmed the vars were stored in User registry.

Related

Proposal

Either:

  1. Honor the env block in ~/.zcode/cli/config.json for built-in tool subprocesses (matching Claude Code docs).
  2. Or inherit user-level environment variables on desktop launch.
  3. Or document clearly that these env vars are CLI-only and provide a ZCode-specific way to set them.

Thanks — happy to provide more diagnostics if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions