Running version on MacOS with iTerm2 and Oh My Zsh/Bash. Installed as per https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-macOS.html
❯ aws2 --version
aws-cli/2.0.0dev0 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0dev0
Installed to:
❯ find /usr/local/bin -name "aws*"
/usr/local/bin/aws2
/usr/local/bin/aws2_completer
/usr/local/bin/aws
/usr/local/bin/aws_completer
aws2_completer
is in path
❯ which aws2_completer
/usr/local/bin/aws2_completer
❯ which aws_completer
/usr/local/bin/aws_completer
Typing aws2 s3 <TAB>
doesn't complete. Doing so with aws s3 <TAB>
does.
Maybe it's user error though. Here's my .bashrc
$ grep aws ~/.bashrc
complete -C '/usr/local/bin/aws_completer' aws
complete -C '/usr/local/bin/aws2_completer' aws2
The error:
$ aws2 sTraceback (most recent call last):
File "aws_completer", line 36, in <module>
File "aws_completer", line 28, in main
File "site-packages/awscli/autocomplete/main.py", line 61, in autocomplete
File "site-packages/awscli/autocomplete/completer.py", line 42, in autocomplete
File "site-packages/awscli/autocomplete/parser.py", line 146, in parse
File "site-packages/awscli/autocomplete/local/model.py", line 106, in arg_names
File "site-packages/awscli/autocomplete/db.py", line 32, in execute
sqlite3.OperationalError: attempt to write a readonly database
[80624] Failed to execute script aws_completer
I've got same issue with aws2
Only slightly different stacktrace
Traceback (most recent call last):
File "aws_completer", line 36, in <module>
File "aws_completer", line 28, in main
File "site-packages/awscli/autocomplete/main.py", line 61, in autocomplete
File "site-packages/awscli/autocomplete/completer.py", line 42, in autocomplete
File "site-packages/awscli/autocomplete/parser.py", line 144, in parse
File "site-packages/awscli/autocomplete/parser.py", line 224, in _split_to_parts
IndexError: string index out of range
aws2 --version output
aws-cli/2.0.0dev0 Python/3.7.4 Darwin/19.0.0 botocore/2.0.0dev0
This is not user error. Currently, auto completion is not functional when installing aws2
via the installers we distribute. This is something we're aware of and are looking into fixing.
I also noticed that there doesnt seem to be an aws2_zsh_completer.sh for zsh shells like there is for the aws v1. Will the auto completer for v2 also require this as well?
I can't use zsh completion with aws2 too!
I added following line in ~/.zshrc
on Mac OS X then it works:
complete -C '/usr/local/bin/aws2_completer' aws2
I added following line in
~/.zshrc
on Mac OS X then it works:
complete -C '/usr/local/bin/aws2_completer' aws2
Thanks! That worked
zsh: command not found: complete
That is error I get when I try that solution
Looks like aws2_completer
works with the current version. Maybe just needs docs to tell people how to configure it if the installer doesn't do it.
❯ aws2 --version
aws-cli/2.0.0dev3 Python/3.7.4 Darwin/19.2.0 botocore/2.0.0dev2
I've modified the oh-my-zsh plugin to use aws2. It's a bit crude but here's a link https://github.com/drgr33n/oh-my-zsh_aws2-plugin
I need to run
bash
autoload bashcompinit
bashcompinit
in my .zshrc before
complete -C '/usr/local/bin/aws_completer' aws
also note you have to remove the 2 if you install the GA version
Documentation needs to be updated, but in the mean time those who are looking for a solution to Oh-My-Zsh completion this will get you to a working spot again...
plugins=(
...
[your plugins here]
...
)
# Check for AWS CLI v2 and enable plugin if exists.
if ! [[ -x "$(command -v aws)" ]]; then
export IS_AWS=False
echo "### Binary for aws not installed."
else
export IS_AWS=True
plugins+=(aws)
fi
# Activate Oh-My-ZSH
autoload bashcompinit
bashcompinit
source ${ZSH}/oh-my-zsh.sh
# Fix to enable AWS CLI v2 completion.
if [[ IS_AWS==True ]]; then
complete -C '/usr/local/bin/aws_completer' aws
fi
Just know you can't use complete
until the oh-my-zsh.sh
is sourced since complete
will fail otherwise. This variation will add aws
to plugins only if it finds the aws cli binary. Hopefully this helps someone avoid a lot of wasted time - it seems as though the lack of documentation from AWS is causing a number of people to have issues. Hopefully someone from AWS will, minimally, address this.
@jonny-rimek what is _GA_ version ? I have put those 3 lines in my .zshrc
and still no completion available :(
GA is generally availabe speaking of v2. during development of v2 the name was aws2. now that v2 is released the name is back to aws.
@cipri-tom you have oh-my-zsh installed and restarted your shell?
@jonny-rimek nop, no OMZ, as I just started I wanna take it slow and understand what is going on.
Restarted, yes. I am getting an error, though:
complete:13: command not found: compdef
when I enable the line of completion, although I have the other 2 lines as well (bashcompinit
). I think it is coming from aws_completer
If you're using Oh My ZSH and have NVM on your system, then
complete -C aws_completer aws
must be put AFTER the NVM stuff in your .zshrs:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
It's probably because $NVM_DIR/bash_completion
rerun autoload bashcompinit
or something like this.
Most helpful comment
I need to run
bash autoload bashcompinit bashcompinit
in my .zshrc before
complete -C '/usr/local/bin/aws_completer' aws
also note you have to remove the 2 if you install the GA version