Azure-cli: az returns stack trace from Powershell but works from cmd

Created on 4 Jun 2019  Â·  5Comments  Â·  Source: Azure/azure-cli

Describe the bug

az returns stack trace when executed from Powershell but works for the command prompt.

Errors:

\# az --version
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-dsvrkf2x\azure-cli\azure\cli\__main__.py", line 33, in <module>
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-dsvrkf2x\azure-cli-core\azure\cli\core\__init__.py", line 515, in get_default_cli
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-dsvrkf2x\azure-cli-core\azure\cli\core\azlogging.py", line 30, in <module>
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-dsvrkf2x\azure-cli-core\azure\cli\core\commands\__init__.py", line 28, in <module>
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-dsvrkf2x\azure-cli-core\azure\cli\core\extension\__init__.py", line 16, in <module>
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-dsvrkf2x\knack\knack\config.py", line 39, in __init__
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-dsvrkf2x\knack\knack\util.py", line 41, in ensure_dir
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\os.py", line 220, in makedirs
    mkdir(name, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'Y:\\\\'

This directory "C:\Users\VSSADM~1" does not exist.

vs.

C:\Users\jlarrow\Documents>az --version
azure-cli                         2.0.65

acr                                2.2.7
acs                                2.4.2
advisor                            2.0.0
ams                                0.4.6
appservice                        0.2.20
backup                             1.2.4
batch                              4.0.1
batchai                            0.4.9
billing                            0.2.1
botservice                         0.2.1
cdn                                0.2.3
cloud                              2.1.1
cognitiveservices                  0.2.5
command-modules-nspkg               2.0.2
configure                         2.0.23
consumption                        0.4.3
container                         0.3.17
core                              2.0.65
cosmosdb                          0.2.10
deploymentmanager                  0.1.0
dla                                0.2.5
dls                                0.1.9
dms                                0.1.3
eventgrid                          0.2.3
eventhubs                          0.3.6
extension                          0.2.5
feedback                           2.2.1
find                               0.3.3
hdinsight                          0.3.4
interactive                        0.4.4
iot                                0.3.9
iotcentral                         0.1.6
keyvault                          2.2.15
kusto                              0.2.2
lab                                0.1.7
maps                               0.3.4
monitor                           0.2.14
natgateway                         0.1.0
network                            2.5.0
nspkg                              3.0.3
policyinsights                     0.1.3
privatedns                         1.0.1
profile                            2.1.5
rdbms                             0.3.11
redis                              0.4.3
relay                              0.1.4
reservations                       0.4.2
resource                          2.1.14
role                               2.6.2
search                             0.1.1
security                           0.1.1
servicebus                         0.3.5
servicefabric                     0.1.19
signalr                            1.0.0
sql                                2.2.4
sqlvm                              0.1.1
storage                            2.4.2
telemetry                          1.0.2
vm                                2.2.21

Extensions:
resource-graph                     0.1.8

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\jlarrow\.azure\cliextensions'

Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal


Unable to check if your CLI is up-to-date. Check your internet connection.

To Reproduce:

I think this is only my system but I can't determine the difference in environment between Powershell and cmd.

[C:\Users\jlarrow\Documents] [15:32:03]
# get-command az | fl


Name            : az.cmd
CommandType     : Application
Definition      : C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
Extension       : .cmd
Path            : C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
FileVersionInfo : File:             C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
                  InternalName:
                  OriginalFilename:
                  FileVersion:
                  FileDescription:
                  Product:
                  ProductVersion:
                  Debug:            False
                  Patched:          False
                  PreRelease:       False
                  PrivateBuild:     False
                  SpecialBuild:     False
                  Language:




[C:\Users\jlarrow\Documents] [15:32:07]
# get-command python | fl


Name            : python.exe
CommandType     : Application
Definition      : C:\Program Files\Python37\python.exe
Extension       : .exe
Path            : C:\Program Files\Python37\python.exe
FileVersionInfo : File:             C:\Program Files\Python37\python.exe
                  InternalName:     Python Console
                  OriginalFilename: python.exe
                  FileVersion:      3.7.3
                  FileDescription:  Python
                  Product:          Python
                  ProductVersion:   3.7.3
                  Debug:            False
                  Patched:          False
                  PreRelease:       False
                  PrivateBuild:     False
                  SpecialBuild:     False
                  Language:         Language Neutral

... and from cmd:

C:\Users\jlarrow\Documents>where az
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd

C:\Users\jlarrow\Documents>where python
C:\Program Files\Python37\python.exe

Expected Behavior

az will work in Powershell

Environment Summary

Windows-10-10.0.17763-SP0
Python 3.6.6
Shell: cmd.exe

azure-cli 2.0.65

Extensions:
resource-graph 0.1.8

Additional Context

Recent installs include:

  • upgrade to 1809
  • VS2019

I uninstalled the python pack from VS2019 thinking there was version interference.

I'd be grateful for any help in narrowing down what may be the issue.

Thanks,
Jody


Packaging question

Most helpful comment

@marstr, Thanks for pointing this out! I didn't realize what that line was telling me. You were correct — I looked at all occurrences of "Y:" in my environment and it turns out $env:HOME was the issue. Now I just have to trace down where it's getting set incorrectly. THANK YOU so much for helping me get this sorted out!

All 5 comments

If you run where az on CMD and get-command az.bat on Powershell, are they pointing to the same path?

There is no at.bat ...

# get-command az.bat
get-command : The term 'az.bat' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ get-command az.bat
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (az.bat:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

... as initially reported in this issue, az from either shell does show the same path "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd".

I'm a bit confounded, @jlarrow! It says it's failing to find an empty file in the Y: drive, did you ever have anything mounted there? Any possibility that you are setting an environment variable in your PowerShell Profile that isn't being set in Command Prompt?

@marstr, Thanks for pointing this out! I didn't realize what that line was telling me. You were correct — I looked at all occurrences of "Y:" in my environment and it turns out $env:HOME was the issue. Now I just have to trace down where it's getting set incorrectly. THANK YOU so much for helping me get this sorted out!

I'm glad I could help, @jlarrow! :)

Was this page helpful?
0 / 5 - 0 ratings