Closed weinong closed 5 years ago
What's the error from az --debug
?
DEBUG: Command arguments ['vm', '-h']
DEBUG: Installed command modules ['acr', 'acs', 'appservice', 'batch', 'cloud', 'component', 'configure', 'container', 'context', 'feedback', 'iot', 'keyvault', 'network', 'profile', 'redis', 'resource', 'role', 'sql', 'storage', 'taskhelp', 'vm']
DEBUG: Registered application event handler 'CommandTableParams.Loaded' at <function add_id_parameters at 0x7f20efd3f598>
DEBUG: Registered application event handler 'CommandTable.Loaded' at <function add_id_parameters at 0x7f20efd3f598>
DEBUG: Loaded module 'acr' in 0.258 seconds.
DEBUG: Loaded module 'acs' in 0.108 seconds.
DEBUG: Loaded module 'appservice' in 0.052 seconds.
DEBUG: Loaded module 'batch' in 0.019 seconds.
DEBUG: Loaded module 'cloud' in 0.001 seconds.
DEBUG: Loaded module 'component' in 0.001 seconds.
DEBUG: Loaded module 'configure' in 0.001 seconds.
DEBUG: Loaded module 'container' in 0.001 seconds.
DEBUG: Loaded module 'context' in 0.002 seconds.
DEBUG: Loaded module 'feedback' in 0.001 seconds.
DEBUG: Loaded module 'iot' in 0.017 seconds.
DEBUG: Loaded module 'keyvault' in 0.040 seconds.
DEBUG: Loaded module 'network' in 0.123 seconds.
DEBUG: Loaded module 'profile' in 0.002 seconds.
DEBUG: Loaded module 'redis' in 0.008 seconds.
DEBUG: Loaded module 'resource' in 0.004 seconds.
DEBUG: Loaded module 'role' in 0.009 seconds.
DEBUG: Loaded module 'sql' in 0.021 seconds.
DEBUG: Loaded module 'storage' in 0.046 seconds.
DEBUG: Loaded module 'taskhelp' in 0.001 seconds.
ERROR: Error loading command module 'vm'
DEBUG: Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/azure/cli/core/commands/init.py", line 247, in get_command_table
import_module('azure.cli.command_modules.' + mod).load_commands()
File "/usr/local/lib/python3.5/site-packages/azure/cli/command_modules/vm/init.py", line 14, in load_commands
import azure.cli.command_modules.vm.commands # pylint: disable=redefined-outer-name
File "/usr/local/lib/python3.5/site-packages/azure/cli/command_modules/vm/commands.py", line 71, in
DEBUG: Loaded all modules in 0.717 seconds. (note: there's always an overhead with the first module loaded) DEBUG: Application event 'CommandTable.Loaded' with event data {'command_table': OrderedDict([('network lb probe show', <azure.cli.core.commands.CliCommand object at 0x7f20ef107cf8>), ('storage container lease release', <azure.cli.core.commands.CliCommand object at 0x7f20eeec8cc0>), ('batch account show', <azure.cli.core.commands.CliCommand object at 0x7f20ef65c470>), ('role assignment list', <azure.cli.core.commands.CliCommand object at 0x7f20ef00fe48>), ('storage blob copy start-batch', <azure.cli.core.commands.CliCommand object at 0x7f20eeedd470>), [...] DEBUG: Application event 'CommandParser.Loaded' with event data {'parser': AzCliCommandParser(prog='az', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)} DEBUG: Application event 'CommandTableParams.Loaded' with event data {'command_table': OrderedDict([('network lb probe show', <azure.cli.core.commands.CliCommand object at 0x7f20ef107cf8>), ('storage container lease release', <azure.cli.core.commands.CliCommand object at 0x7f20eeec8cc0>), ('batch account show', <azure.cli.core.commands.CliCommand object at 0x7f20ef65c470>), ('role assignment list', <azure.cli.core.commands.CliCommand object at 0x7f20ef00fe48>), ('storage blob copy start-batch', <azure.cli.core.commands.CliCommand object at 0x7f20eeedd470>), [...] DEBUG: Checking PyPI for modules using query '{'author_email': 'azpycli', 'author': 'Microsoft Corporation'}' DEBUG: Found 24 result(s) DEBUG: Found module that matches 'vm' - {'summary': 'Microsoft Azure Command-Line Tools VM Command Module', '_pypi_ordering': False, 'version': '0.1.1b3', 'name': 'azure-cli-vm'} WARNING: Install the 'vm' module with 'az component update --add vm' ERROR: az: error: argument _command_package: invalid choice: 'vm' (choose from 'network', 'storage', 'batch', 'role', 'keyvault', 'account', 'acs', 'resource', 'policy', 'acr', 'tag', 'sql', 'iot', 'appservice', 'group', 'component', 'context', 'ad', 'redis', 'cloud', 'feature', 'feedback', 'configure', 'container', 'provider', 'login', 'logout', 'taskhelp') usage: az [-h] [--output {json,tsv,list,table,jsonc}] [--verbose] [--debug] [--query JMESPATH] {network,storage,batch,role,keyvault,account,acs,resource,policy,acr,tag,sql,iot,appservice,group,component,context,ad,redis,cloud,feature,feedback,configure,container,provider,login,logout,taskhelp} ...
the same thing also happens when using my own Docker image where the cli is installed through pip and .deb.
Try setting the USER
environment variable with -e USER=weinong
The CLI attempts to get the current logged in user. When you do -u
in the Docker command, the name is not set.
https://docs.python.org/2/library/getpass.html#getpass.getuser
nice. it does the trick. though, can we guard it so that it doesn't simply bail out even when we are not doing any vm stuffs?
Changed the title of the issue to reflect the real issue. Thanks for the feedback and bug report.
getpass.getuser()
can throw an exception. The CLI should catch this and not prevent a module from being loaded.
Consider wrapping our usage of getpass.getuser()
in a central place in the CLI.
I am using docker image. With the default root user, everything is fine. However, when I use non-root user, it's not able to load some module.