Skip to content

Pass DATABRICKS_CLI_PATH to subprocess environment in DatabricksCliAuthProvider#1903

Closed
DM87 wants to merge 1 commit into
databricks:mainfrom
DM87:#1896
Closed

Pass DATABRICKS_CLI_PATH to subprocess environment in DatabricksCliAuthProvider#1903
DM87 wants to merge 1 commit into
databricks:mainfrom
DM87:#1896

Conversation

@DM87

@DM87 DM87 commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Fixes #1896

Bundle operations (deploy, validate) fail with databricks CLI not found since v2.10.7 because the spawned CLI subprocess cannot locate itself for token refresh.

Root cause

The CLI bump from v0.286.0 to v0.297.2 brought Go SDK v0.126.0, which changed the databricks-cli auth strategy to invoke the CLI binary (via cli_token_source.gofindDatabricksCli()) instead of refreshing tokens in-process.

DatabricksCliAuthProvider.toEnv() sets DATABRICKS_AUTH_TYPE=databricks-cli but never sets DATABRICKS_CLI_PATH. The spawned CLI sees an empty DatabricksCliPath, falls back to searching PATH, and fails because the extension's bin/ directory isn't on the system PATH.

The in-process SDK config (_getSdkConfig()) already passes databricksCliPath: this.cliPath correctly — the subprocess environment just needs the same treatment.

Changes

  • Add DATABRICKS_CLI_PATH: this.cliPath to toEnv() in DatabricksCliAuthProvider

Test plan

  • Untested — submitting based on code analysis only
  • Existing unit tests pass
  • Bundle deploy no longer errors with "databricks CLI not found"

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/vscode

Inputs:

  • PR number: 1903
  • Commit SHA: 832b6dc8ed44c181b16dcfb2df55936a413c8213

Checks will be approved automatically on success.

@anton-107

Copy link
Copy Markdown
Contributor

Please watch #1908 for the fix

@anton-107 anton-107 closed this Jun 15, 2026
rugpanov added a commit that referenced this pull request Jun 16, 2026
…#1910)

## Why
- On Windows, `databricks bundle` deploys fail with `databricks CLI not
found` because the SDK / Terraform provider can't locate the bundled CLI
when running in a subprocess.
- The path that was forwarded was extensionless (`bin/databricks`), but
the bundled Windows binary is `databricks.exe`. The Go SDK / Terraform
provider do a literal file lookup and do **not** auto-append `.exe` the
way Windows' `CreateProcess` does — so the lookup fails.
- The legacy `.databricks/project.json` persisted the bundled CLI path
(`databricksPath`), and `AuthProvider.fromJSON` preferred it over the
freshly resolved path. That snapshot is version-pinned and, on Windows,
was stored without `.exe`, so it overrode the corrected path during
legacy→bundle migration.

This builds on #1903 (which adds the `DATABRICKS_CLI_PATH` env var) by
also making the path it forwards correct on Windows and not letting a
stale persisted path win.

## What
- Forward the resolved CLI path to subprocesses via the
`DATABRICKS_CLI_PATH` env var so they don't fall back to a `PATH` search
(`DatabricksCliAuthProvider.toEnv`).
- Make `CliWrapper.cliPath` return the platform-specific binary name:
`databricks.exe` on `win32`, `databricks` elsewhere.
- In `AuthProvider.fromJSON`, always use the freshly resolved bundled
CLI path and ignore the persisted `databricksPath` — it's an
extension-managed, version-pinned value that is stale after any upgrade.
(`fromSdkConfig` is intentionally left alone, since its
`databricksCliPath` comes live from the user's `.databrickscfg`.)
- Added explanatory comments at each site.

## Verification
- Added unit tests for: the platform-specific binary name, `toEnv()`
exposing `DATABRICKS_CLI_PATH`, and `fromJSON` ignoring a stale
persisted `databricksPath`. Suite passes in the VS Code test host (14
relevant tests green).
- Built the `win32-x64` VSIX and confirmed the bundled
`extension/out/extension.js` contains both the env var and the `.exe`
path, with `bin/databricks.exe` packaged.

This pull request and its description were written by Isaac.
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.

[BUG] Error: cannot read X: databricks CLI not found.

2 participants