From f26806be8f688e48526bffe6a3e8c28fd3c556df Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Mon, 3 Apr 2023 16:23:53 +0200 Subject: [PATCH] Set BRICKS_CLI_PATH only if it cannot be derived from $PATH (#298) ## Changes Related to #237. Output of `bricks auth env` now doesn't include `BRICKS_CLI_PATH` if it can be found in $PATH. ## Tests Verified manually. --- bundle/config/workspace.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bundle/config/workspace.go b/bundle/config/workspace.go index d6c83b770..ce989b53d 100644 --- a/bundle/config/workspace.go +++ b/bundle/config/workspace.go @@ -2,6 +2,7 @@ package config import ( "os" + "path/filepath" "github.com/databricks/bricks/libs/databrickscfg" "github.com/databricks/databricks-sdk-go" @@ -103,5 +104,11 @@ func (w *Workspace) Client() (*databricks.WorkspaceClient, error) { } func init() { - os.Setenv("BRICKS_CLI_PATH", os.Args[0]) + arg0 := os.Args[0] + + // Configure BRICKS_CLI_PATH only if our caller intends to use this specific version of this binary. + // Otherwise, if it is equal to its basename, processes can find it in $PATH. + if arg0 != filepath.Base(arg0) { + os.Setenv("BRICKS_CLI_PATH", arg0) + } }