"aws sso login" returns "command not found" error

0

When I run aws sso login I get the following error:

$ aws sso login
aws sso login: command not found

All other aws commands work fine.

aws sso help returns the sso man page with a description and available commands:

 AVAILABLE COMMANDS
       o get-role-credentials
       o help
       o list-account-roles
       o list-accounts
       o login
       o logout

I get the same error for the other aws sso commands (except help):

$ aws sso logout
aws sso logout: command not found

$ aws sso get-role-credentials
aws sso get-role-credentials: command not found

$ aws sso list-account-roles
aws sso list-account-roles: command not found

$ aws sso list-accounts
aws sso list-accounts: command not found

Using:

 $ aws --version
aws-cli/2.11.2 Python/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 prompt/off

Installed following these instructions.

Debug output:

$ aws --debug sso login
2023-03-14 11:30:36,369 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.11.2 Python/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22
2023-03-14 11:30:36,369 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['--debug', 'sso', 'login']
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_s3 at 0x7f030ab953a0>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_ddb at 0x7f030b5d6840>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.configure.configure.ConfigureCommand'>>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x7f030b554a40>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x7f030b5560c0>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function alias_opsworks_cm at 0x7f030ab97880>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_history_commands at 0x7f030af25260>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.devcommands.CLIDevCommand'>>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_waiters at 0x7f030ab97740>
2023-03-14 11:30:36,383 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x7f030a151750>>
2023-03-14 11:30:36,384 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/v2/2.11.2/dist/awscli/data/cli.json
2023-03-14 11:30:36,387 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_types at 0x7f030afd6ac0>
2023-03-14 11:30:36,387 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function no_sign_request at 0x7f030afd6de0>
2023-03-14 11:30:36,387 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_verify_ssl at 0x7f030afd6d40>
2023-03-14 11:30:36,387 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_read_timeout at 0x7f030afd6f20>
2023-03-14 11:30:36,388 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_connect_timeout at 0x7f030afd6e80>
2023-03-14 11:30:36,388 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <built-in method update of dict object at 0x7f030a14eac0>
2023-03-14 11:30:36,388 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.11.2 Python/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 prompt/off
2023-03-14 11:30:36,388 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['--debug', 'sso', 'login']
2023-03-14 11:30:36,388 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_timestamp_parser at 0x7f030ab95d00>
2023-03-14 11:30:36,388 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x7f030bd30220>
2023-03-14 11:30:36,388 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_binary_formatter at 0x7f030a120d60>
2023-03-14 11:30:36,388 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function no_pager_handler at 0x7f030bd04a40>
2023-03-14 11:30:36,388 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x7f030bd51b20>
2023-03-14 11:30:36,389 - MainThread - botocore.utils - DEBUG - IMDS ENDPOINT: http://169.254.169.254/
2023-03-14 11:30:36,391 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x7f030af09b20>
2023-03-14 11:30:36,391 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_json_file_cache at 0x7f030b5beac0>
2023-03-14 11:30:36,400 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/v2/2.11.2/dist/awscli/botocore/data/sso/2019-06-10/service-2.json
2023-03-14 11:30:36,402 - MainThread - botocore.hooks - DEBUG - Event building-command-table.sso: calling handler <function add_sso_commands at 0x7f030b5bcea0>
2023-03-14 11:30:36,402 - MainThread - botocore.hooks - DEBUG - Event building-command-table.sso: calling handler <function add_waiters at 0x7f030ab97740>
2023-03-14 11:30:36,409 - MainThread - botocore.hooks - DEBUG - Event building-command-table.sso: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x7f030a151750>>
2023-03-14 11:30:36,411 - MainThread - botocore.hooks - DEBUG - Event building-command-table.sso_login: calling handler <function add_waiters at 0x7f030ab97740>
2023-03-14 11:30:36,411 - MainThread - botocore.hooks - DEBUG - Event building-command-table.sso_login: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x7f030a151750>>
2023-03-14 11:30:36,411 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.login.no-browser: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f030a185650>
2023-03-14 11:30:36,412 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.custom.login: calling handler <awscli.argprocess.ParamShorthandParser object at 0x7f030ab99c10>
2023-03-14 11:30:36,412 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.login.sso-session: calling handler <awscli.paramfile.URIArgumentHandler object at 0x7f030a185650>
2023-03-14 11:30:36,412 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "awscli/clidriver.py", line 460, in main
  File "awscli/clidriver.py", line 595, in __call__
  File "awscli/customizations/commands.py", line 205, in __call__
  File "awscli/customizations/sso/login.py", line 43, in _run_main
  File "awscli/customizations/sso/utils.py", line 166, in _get_sso_config
  File "awscli/customizations/sso/utils.py", line 195, in _get_legacy_sso_config

I tried uninstalling following these instructions and installing again, that didn't solve the problem.

Running /usr/local/bin/aws sso login works.

$ which aws
/usr/local/bin/aws

$ whereis aws
aws: /usr/local/bin/aws

# There are no alias for aws
$ alias | grep aws

Running it as an alias also works:

$ aws sso login
aws sso login: command not found

$ alias pippo='aws sso login'

$ pippo
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:
https://device.sso.eu-west-1.amazonaws.com/

What can I do to troubleshoot this issue?

1 Answer
1

Did you try it with --debug -option? That could reveal where the problem is.

aws --debug sso login

My guess is, there is some trouble finding your default browser.

profile picture
EXPERT
Kallu
answered a year ago
  • Thanks! I did that and added the output to the question (it was too big for a comment). I also added that both running as /usr/local/bin/aws sso login and from an alias work fine.

  • I think this something with your shell rather than aws-cli. "aws sso login: command not found" says it can not find cmd "aws sso login", like it was ignoring whitespaces between cmd and arguments. Everything else seems to work; debug-flag, fullpath, even "aws sso help", but not "aws sso login". I can get similar error if I add quotes around cmd and parameters.

    $ 'aws sso help' -bash: aws sso help: command not found

    Have you checked you don't have function called "aws" defined?

    $ typeset -F | grep aws

  • @Kallu I suspect you are right, something is wrong with my shell. It is peculiar it only happens with aws. typeset -F | grep aws produces no output.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions