microsoft / vscode-azurecli

VS Code extension for the Azure CLI 2.0
MIT License
71 stars 46 forks source link

Relative paths #62

Open jessetechie opened 4 years ago

jessetechie commented 4 years ago

I tried executing a command that takes a file path, like

az group deployment validate --template-file template.json --parameters @parameters.json

But I kept getting

{
    "stderr": "ERROR: [Errno 2] No such file or directory: 'template.json'\r\n",
    "stdout": ""
}

I was somewhat surprised when I ran dir from the editor, that it returned the contents of ~\AppData\Local\Programs\Microsoft VS Code (this is Windows obv).

Do I always have to provide a full path to a file, or is there a way to make a relative path work?

Then, as a workaround, I ran the above command in the terminal (which is Powershell) after ensuring it was in the right directory, and got a different error related to the @ sign required by the --parameters option:

The splatting operator '@' cannot be used to reference variables in an expression. '@parameters' can be used only as an argument to a command. To reference variables in an expression use '$parameters'.

I was able to get around this by quoting the value, so I guess YMMV from one shell to another. Which is a little disappointing from a cross-platform perspective but not really your problem.

So to sum up, in order to run an az command that takes a file, it seems like currently I either have to provide a full path, or:

chrmarti commented 4 years ago

We should pass the .azcli file's folder as working directory: https://github.com/microsoft/vscode-azurecli/blob/0ac34e2214078270b63cf6716423d40a60423834/src/extension.ts#L200