Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.96k forks source link

Can't upgrade in WSL2: UNC paths are not supported. #22663

Open magodo opened 2 years ago

magodo commented 2 years ago

Related command

❯ az version
{
  "azure-cli": "2.35.0",
  "azure-cli-core": "2.35.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {}
}

❯ az upgrade
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Your current Azure CLI version is 2.35.0. Latest version available is 2.37.0.
Please check the release notes first: https://docs.microsoft.com/cli/azure/release-notes-azure-cli
Do you want to continue? (Y/n): y
Not able to upgrade automatically. Instructions can be found at https://aka.ms/doc/InstallAzureCli
'\\wsl$\Ubuntu\home\magodo\github\terraform-provider-azurerm'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
CLI upgrade failed or aborted.

Additional context

I'm running this under WSL2, Ubuntu distribution:

❯ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
yonzhan commented 2 years ago

@jiasli for awareness

jiasli commented 2 years ago

az upgrade currently doesn't support WSL. Please follow the official doc to update: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt

sudo apt-get update && sudo apt-get install --only-upgrade -y azure-cli
magodo commented 2 years ago

@yonzhan Why do you just close this issue given it is not resolved?

yonzhan commented 2 years ago

@magodo I thought Jiashuo provided you solution/workaround. I can reopen it and add it as feature request in our backlog.

RobertoPrevato commented 1 year ago

az upgrade currently doesn't support WSL. Please follow the official doc to update: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt

sudo apt-get update && sudo apt-get install --only-upgrade -y azure-cli

This didn't work for me. I didn't have azure-cli installed on WSL2 OS, instead it was using the one from Windows. I didn't recall about this. So first check:

which az

In my case: /mnt/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin/az.

If the Azure CLI is from Windows, run az upgrade from PowerShell in Windows instead.

Nivi09 commented 1 year ago

Tried the above solution, but az upgrade did not upgrade the cli. So, problem is still not resolved.