Skip to content

Commit

Permalink
Fix az login on Windows under cmd.exe (#1513)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
ilia-db authored Jan 9, 2025
1 parent 1157a83 commit 4a042a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/databricks-vscode/scripts/fetch-databricks-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi

CLI_DIR=$(mktemp -d -t databricks-XXXXXXXXXX)
pushd $CLI_DIR
gh release download v${CLI_VERSION} --pattern "databricks_cli_${CLI_VERSION}_${CLI_ARCH}.zip" --repo databricks/cli
curl -L -O "https://github.com/databricks/cli/releases/download/v${CLI_VERSION}/databricks_cli_${CLI_VERSION}_${CLI_ARCH}.zip"
unzip databricks_*_$CLI_ARCH.zip
rm databricks_*_$CLI_ARCH.zip
ls
Expand Down
7 changes: 4 additions & 3 deletions packages/databricks-vscode/src/cli/CliWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ function getEscapedCommandAndAgrs(
options: SpawnOptionsWithoutStdio
) {
if (process.platform === "win32") {
const cmdArgs = args.slice();
args = [
"/d", //Disables execution of AutoRun commands, which are like .bashrc commands.
"/c", //Carries out the command specified by <string> and then exits the command processor.
`""${cmd}" ${args.map((a) => `"${a}"`).join(" ")}"`,
"/d", // Disables execution of AutoRun commands, which are like .bashrc commands.
"/c", // Carries out the command specified by <string> and then exits the command processor.
`""${cmd}" ${cmdArgs.map((a) => `"${a}"`).join(" ")}"`,
];
cmd = "cmd.exe";
options = {...options, windowsVerbatimArguments: true};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Loggers} from "../../logger";
import {AzureCliAuthProvider} from "./AuthProvider";
import {orchestrate, OrchestrationLoopError, Step} from "./orchestrate";
import {ShellUtils} from "../../utils";
import {execFile} from "../../cli/CliWrapper";
import {cancellableExecFile} from "../../cli/CliWrapper";
import {
FileNotFoundException,
isFileNotFound,
Expand Down Expand Up @@ -40,7 +40,12 @@ async function execFileWithShell(
stderr: string;
}> {
try {
return await execFile(cmd, args, {shell: true}, cancellationToken);
return await cancellableExecFile(
cmd,
args,
{shell: true},
cancellationToken
);
} catch (e) {
if (isFileNotFound(e)) {
throw new FileNotFoundException(e.message);
Expand Down

0 comments on commit 4a042a7

Please sign in to comment.