trek10inc / awsume

A utility for easily assuming AWS IAM roles from the command line.
https://awsu.me
MIT License
487 stars 90 forks source link

kill-refresher Generating error /usr/local/bin/awsume: line 85: return: can only `return' from a function or sourced script #154

Closed grygiel closed 3 years ago

grygiel commented 3 years ago

After starting the auto refresh process I tried to kill the refresher with the command below ... I have issued the command with --debug to provide additional information.
Is this the correct way to trigger this event? I am running version : 4.5.0

sh-4.2# awsume --kill-refresher --debug [2021-05-12 16:15:08,888] main.py:main : [DEBUG] Debug logs are visible [2021-05-12 16:15:08,889] main.py:main : [DEBUG] Executing awsume [2021-05-12 16:15:08,889] app.py:init : [DEBUG] Initalizing app [2021-05-12 16:15:08,889] app.py:get_plugin_manager : [DEBUG] Creating plugin manager [2021-05-12 16:15:08,890] app.py:get_plugin_manager : [DEBUG] Loading plugins [2021-05-12 16:15:08,898] app.py:parse_args : [DEBUG] Gathering arguments [2021-05-12 16:15:08,900] default_plugins.py:add_arguments : [INFO] Adding arguments [2021-05-12 16:15:08,901] app.py:parse_args : [DEBUG] Parsing arguments [2021-05-12 16:15:08,901] app.py:parse_args : [DEBUG] Handling arguments [2021-05-12 16:15:08,901] default_plugins.py:post_add_arguments : [DEBUG] Post add arguments [2021-05-12 16:15:08,902] default_plugins.py:post_add_arguments : [DEBUG] {"version": false, "output_profile": null, "clean": false, "profile_name": null, "force_refresh": false, "show_commands": false, "unset_variables": false, "auto_refresh": false, "kill": true, "list_profiles": null, "refresh_autocomplete": false, "role_arn": null, "principal_arn": null, "source_profile": null, "external_id": null, "mfa_token": null, "region": null, "session_name": null, "role_duration": null, "with_saml": false, "with_web_identity": false, "json": null, "credentials_file": null, "config_file": null, "config": null, "list_plugins": false, "info": false, "debug": true} [2021-05-12 16:15:08,902] process.py:kill : [DEBUG] Stopping all auto refreshing and removing autoawsume profiles [2021-05-12 16:15:08,902] process.py:kill_autoawsume : [DEBUG] Killing autoawsume [2021-05-12 16:15:08,904] app.py:run : [DEBUG] Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/awsume/awsumepy/app.py", line 261, in run args = self.parse_args(system_arguments) File "/usr/local/lib/python3.6/site-packages/awsume/awsumepy/app.py", line 85, in parse_args parser=argument_parser, File "/usr/local/lib/python3.6/site-packages/pluggy/hooks.py", line 286, in call return self._hookexec(self, self.get_hookimpls(), kwargs) File "/usr/local/lib/python3.6/site-packages/pluggy/manager.py", line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/usr/local/lib/python3.6/site-packages/pluggy/manager.py", line 87, in firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "/usr/local/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall return outcome.get_result() File "/usr/local/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "/usr/local/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall res = hook_impl.function(*args) File "/usr/local/lib/python3.6/site-packages/awsume/awsumepy/default_plugins.py", line 226, in post_add_arguments raise exceptions.EarlyExit() awsume.awsumepy.lib.exceptions.EarlyExit: Early exit exception, nothing left to do [2021-05-12 16:15:08,906] app.py:run : [DEBUG] EarlyExit exception raised, no more work to do /usr/local/bin/awsume: line 85: return: can only `return' from a function or sourced script

mbarneyjr commented 3 years ago

The awsume shell script expects to be sourced. To help make this easier, an alias is attempted to be installed automatically to your login file (~/.bashrc, ~/.zshrc, etc, but can sometimes fail for a variety of reasons). To help set it up after installation, you can use awsume-configure (see the docs here). On version 4.5.1, you can run awsume-configure on it's own without any arguments, and it will attempt to set awsume up for each installed supported shell you have.

Assuming the alias is defined in your login file, it should be made available every time you open your terminal. If you're still experiencing issues feel free to reopen this issue or create a new one!