Skip to content

Commit 626e134

Browse files
authored
Fix bundle-init on windows (#1058)
Supply full environment to the terminal (but still use `strictEnv` to ignore environmentCollection) Also use cross-platform read function.
1 parent c4f25a2 commit 626e134

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

packages/databricks-vscode/src/bundle/BundleInitWizard.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {LoginWizard} from "../configuration/LoginWizard";
1313
import {CliWrapper} from "../cli/CliWrapper";
1414
import {getSubProjects} from "./BundleFileSet";
1515
import {tmpdir} from "os";
16+
import {ShellUtils} from "../utils";
1617

1718
export async function promptToOpenSubProjects(
1819
projects: {absolute: Uri; relative: Uri}[]
@@ -141,7 +142,12 @@ export class BundleInitWizard {
141142
name: "Databricks Project Init",
142143
isTransient: true,
143144
location: TerminalLocation.Editor,
144-
env: this.cli.getBundleInitEnvVars(authProvider),
145+
env: {
146+
// Without supplying full environment and with `strictEnv: true` PowerShell will fail to start.
147+
// On unix-like systems we don't require full environment, but it doesn't hurt.
148+
...process.env,
149+
...this.cli.getBundleInitEnvVars(authProvider),
150+
},
145151
// Without strict env we will inherit our environmentVariableCollection
146152
// which will override auth env vars we provide in this call.
147153
strictEnv: true,
@@ -156,7 +162,7 @@ export class BundleInitWizard {
156162
this.cli.escapePathArgument(parentFolder.fsPath),
157163
].join(" ");
158164
const initialPrompt = `clear; echo "Executing: databricks ${args}\nFollow the steps below to create your new Databricks project.\n"`;
159-
const finalPrompt = `echo "Press any key to close the terminal and continue ..."; read; exit`;
165+
const finalPrompt = `echo "\nPress any key to close the terminal and continue ..."; ${ShellUtils.readCmd()}; exit`;
160166
terminal.sendText(
161167
`${initialPrompt}; ${this.cli.cliPath} ${args}; ${finalPrompt}`
162168
);

packages/databricks-vscode/src/configuration/auth/AzureCliCheck.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {commands, Disposable, Uri, window} from "vscode";
88
import {Loggers} from "../../logger";
99
import {AzureCliAuthProvider} from "./AuthProvider";
1010
import {orchestrate, OrchestrationLoopError, Step} from "./orchestrate";
11+
import {ShellUtils} from "../../utils";
1112

1213
// eslint-disable-next-line @typescript-eslint/naming-convention
1314
const {NamedLogger} = logging;
@@ -317,7 +318,7 @@ export class AzureCliCheck implements Disposable {
317318
this.azBinPath
318319
} login --allow-no-subscriptions ${useDeviceCode} ${
319320
tenant ? "-t " + tenant : ""
320-
}; echo "Press any key to close the terminal and continue ..."; read; exit`
321+
}; echo "Press any key to close the terminal and continue ..."; ${ShellUtils.readCmd()}; exit`
321322
);
322323

323324
return await Promise.race<boolean>([

packages/databricks-vscode/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * as FileUtils from "./fileUtils";
22
export * as UrlUtils from "./urlUtils";
3+
export * as ShellUtils from "./shellUtils";
34
export * as UtilsCommands from "./UtilsCommands";
45
export * as PackageJsonUtils from "./packageJsonUtils";
56
export * as EnvVarGenerators from "./envVarGenerators";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {env} from "vscode";
2+
3+
export function readCmd() {
4+
if (env.shell.toLowerCase().includes("powershell")) {
5+
return "Read-Host";
6+
}
7+
return "read";
8+
}

0 commit comments

Comments
 (0)