fix(windows): resolve Claude binary path and apiKeyHelper shell syntax on Windows#137
Open
yakup-ozturk wants to merge 1 commit into
Open
fix(windows): resolve Claude binary path and apiKeyHelper shell syntax on Windows#137yakup-ozturk wants to merge 1 commit into
yakup-ozturk wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(windows): resolve Claude binary path and apiKeyHelper syntax on Windows:
Three changes that make
ucode claudework on Windows without manual workarounds:WinError 2 — Claude binary not found (
agents/claude.py) Python'ssubprocessresolves PATH differently from cmd.exe and cannot find npm.cmdwrappers by name. ResolveCLAUDE_BINARYby walking from theclaude.cmdwrapper to the actualclaude.exeinside 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.apiKeyHelper shell syntax error on Windows (
databricks.py) Claude Code runs theapiKeyHelpercommand viacmd.exeon Windows, which rejects the POSIX[ -n "$VAR" ]/env -u/jqsyntax currently emitted bybuild_auth_shell_command. Onos.name == 'nt'the function now returns apython -c "..."one-liner that handles theDATABRICKS_BEARERshort- circuit and calls the Databricks CLI withsubprocess, avoiding both the bash syntax and thejqdependency. POSIX behaviour is unchanged.Settings not visible to the Claude desktop / IDE extension (
agents/claude.py)ucode claudewrites config to~/.claude/ucode-settings.jsonand passes--settingswhen launching the CLI, but the Claude desktop app and IDE extensions read~/.claude/settings.jsonby default. After writing the ucode-managed file, also merge the auth/env overlay intosettings.jsonso theapiKeyHelperandANTHROPIC_*vars are available in every launch path. A backup of the pre-existingsettings.jsonis 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