Skip to content

fix(windows): resolve Claude binary path and apiKeyHelper shell syntax on Windows#137

Open
yakup-ozturk wants to merge 1 commit into
databricks:mainfrom
yakup-ozturk:fix/windows-support
Open

fix(windows): resolve Claude binary path and apiKeyHelper shell syntax on Windows#137
yakup-ozturk wants to merge 1 commit into
databricks:mainfrom
yakup-ozturk:fix/windows-support

Conversation

@yakup-ozturk
Copy link
Copy Markdown

fix(windows): resolve Claude binary path and apiKeyHelper syntax on Windows:

Three changes that make ucode claude work on Windows without manual workarounds:

  1. WinError 2 — Claude binary not found (agents/claude.py) Python's subprocess resolves PATH differently from cmd.exe and cannot find npm .cmd wrappers by name. Resolve CLAUDE_BINARY by walking from the claude.cmd wrapper to the actual claude.exe inside the npm package tree. Falls back to the wrapper path (or the bare "claude" string) if the .exe is absent, so non-Windows installs and non-standard npm layouts are unaffected.

  2. apiKeyHelper shell syntax error on Windows (databricks.py) Claude Code runs the apiKeyHelper command via cmd.exe on Windows, which rejects the POSIX [ -n "$VAR" ] / env -u / jq syntax currently emitted by build_auth_shell_command. On os.name == 'nt' the function now returns a python -c "..." one-liner that handles the DATABRICKS_BEARER short- circuit and calls the Databricks CLI with subprocess, avoiding both the bash syntax and the jq dependency. POSIX behaviour is unchanged.

  3. Settings not visible to the Claude desktop / IDE extension (agents/claude.py) ucode claude writes config to ~/.claude/ucode-settings.json and passes --settings when launching the CLI, but the Claude desktop app and IDE extensions read ~/.claude/settings.json by default. After writing the ucode-managed file, also merge the auth/env overlay into settings.json so the apiKeyHelper and ANTHROPIC_* vars are available in every launch path. A backup of the pre-existing settings.json is created alongside the existing ucode-settings backup.

Reference: https://medium.com/@Yakup-Ozturk/getting-claude-code-to-work-with-the-databricks-ai-gateway-on-windows-three-fixes-i-wish-i-knew-f6e71ece06a9

…x on Windows

Three changes that make `ucode claude` work on Windows without manual workarounds:

1. **WinError 2 — Claude binary not found** (`agents/claude.py`)
   Python's `subprocess` resolves PATH differently from cmd.exe and cannot find
   npm `.cmd` wrappers by name. Resolve `CLAUDE_BINARY` by walking from the
   `claude.cmd` wrapper to the actual `claude.exe` inside the npm package tree.
   Falls back to the wrapper path (or the bare `"claude"` string) if the .exe
   is absent, so non-Windows installs and non-standard npm layouts are unaffected.

2. **apiKeyHelper shell syntax error on Windows** (`databricks.py`)
   Claude Code runs the `apiKeyHelper` command via `cmd.exe` on Windows, which
   rejects the POSIX `[ -n "$VAR" ]` / `env -u` / `jq` syntax currently emitted
   by `build_auth_shell_command`. On `os.name == 'nt'` the function now returns
   a `python -c "..."` one-liner that handles the `DATABRICKS_BEARER` short-
   circuit and calls the Databricks CLI with `subprocess`, avoiding both the bash
   syntax and the `jq` dependency. POSIX behaviour is unchanged.

3. **Settings not visible to the Claude desktop / IDE extension** (`agents/claude.py`)
   `ucode claude` writes config to `~/.claude/ucode-settings.json` and passes
   `--settings` when launching the CLI, but the Claude desktop app and IDE
   extensions read `~/.claude/settings.json` by default.  After writing the
   ucode-managed file, also merge the auth/env overlay into `settings.json` so
   the `apiKeyHelper` and `ANTHROPIC_*` vars are available in every launch path.
   A backup of the pre-existing `settings.json` is created alongside the existing
   ucode-settings backup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant