Skip to content

Commit 4a042a7

Browse files
authored
Fix az login on Windows under cmd.exe (#1513)
## Changes If the default windows shell is cmd.exe, the az login fails due to our handling of the command arguments. We've added the arg handling to fix issues when the vscode is installed in the folder that contains spaces, and so our databricks cli calls were failing. AZ cli doesn't have the same problems, as it's installed separately from the extension, so here I'm reverting back to using execFile without custom argument handling. Fixes #1468 <!-- Summary of your changes that are easy to understand --> ## Tests On win vm
1 parent 1157a83 commit 4a042a7

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

packages/databricks-vscode/scripts/fetch-databricks-cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515

1616
CLI_DIR=$(mktemp -d -t databricks-XXXXXXXXXX)
1717
pushd $CLI_DIR
18-
gh release download v${CLI_VERSION} --pattern "databricks_cli_${CLI_VERSION}_${CLI_ARCH}.zip" --repo databricks/cli
18+
curl -L -O "https://github.com/databricks/cli/releases/download/v${CLI_VERSION}/databricks_cli_${CLI_VERSION}_${CLI_ARCH}.zip"
1919
unzip databricks_*_$CLI_ARCH.zip
2020
rm databricks_*_$CLI_ARCH.zip
2121
ls

packages/databricks-vscode/src/cli/CliWrapper.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ function getEscapedCommandAndAgrs(
3333
options: SpawnOptionsWithoutStdio
3434
) {
3535
if (process.platform === "win32") {
36+
const cmdArgs = args.slice();
3637
args = [
37-
"/d", //Disables execution of AutoRun commands, which are like .bashrc commands.
38-
"/c", //Carries out the command specified by <string> and then exits the command processor.
39-
`""${cmd}" ${args.map((a) => `"${a}"`).join(" ")}"`,
38+
"/d", // Disables execution of AutoRun commands, which are like .bashrc commands.
39+
"/c", // Carries out the command specified by <string> and then exits the command processor.
40+
`""${cmd}" ${cmdArgs.map((a) => `"${a}"`).join(" ")}"`,
4041
];
4142
cmd = "cmd.exe";
4243
options = {...options, windowsVerbatimArguments: true};

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Loggers} from "../../logger";
99
import {AzureCliAuthProvider} from "./AuthProvider";
1010
import {orchestrate, OrchestrationLoopError, Step} from "./orchestrate";
1111
import {ShellUtils} from "../../utils";
12-
import {execFile} from "../../cli/CliWrapper";
12+
import {cancellableExecFile} from "../../cli/CliWrapper";
1313
import {
1414
FileNotFoundException,
1515
isFileNotFound,
@@ -40,7 +40,12 @@ async function execFileWithShell(
4040
stderr: string;
4141
}> {
4242
try {
43-
return await execFile(cmd, args, {shell: true}, cancellationToken);
43+
return await cancellableExecFile(
44+
cmd,
45+
args,
46+
{shell: true},
47+
cancellationToken
48+
);
4449
} catch (e) {
4550
if (isFileNotFound(e)) {
4651
throw new FileNotFoundException(e.message);

0 commit comments

Comments
 (0)