I am running Amazon Linux AMI release 2015.09 on an EC2 instance, and the login shell is zsh 5.0.2 (x86_64-redhat-linux-gnu).
Every time I login to the machine via ssh, I get this error message:
complete:13: command not found: compdef
This error is caused from the last line of aws_zsh_completer.sh, and seems related to this commit.
I didn't find any duplicate issues here.
Any plans for fixing?
We can look into it. Did you setup the CLI's completer or does it happen even though you never set the completer up on your EC2 instance?
All I did was launch a new Amazon Linux AMI 2015.09 instance and sudo yum install zsh
.
No other steps are necessary to reproduce this.
Thanks! We will look into it then.
Oh nice, we diagnosed this bug in Oh My Zsh some weeks ago. Here's the full explanation: https://github.com/robbyrussell/oh-my-zsh/issues/4771#issuecomment-181122099
TL;DR: the /etc/profile.d/aws-cli.sh
file sources the aws-cli completion without having run compinit
first.
Let me know if I can help provide a solution to this.
Cheers!
But IIRC the point here also is to not call compinit
- which should be done only once (by the user).
That's correct. The problem is that the aws-cli.sh
file is loaded in /etc/zshrc
(see below), which is run before the user's zshrc file has had a chance to run compinit
.
A potential user solution is calling compinit
in their zshenv
file (which is run before zshrc), but that will make it an ugly hack and it doesn't play well with the current state of dotfiles that run compinit on zshrc files.
A better, more robust solution coming from AWS itself is converting the aws_zsh_completer.sh
file into a proper completion file that can be autoloaded when completion is triggered.
There's even a comment in that file that talks about this, so perhaps this is the time to put it to practice :smile: :
# It is planned to write a proper zsh auto completion soon. Please talk
# to Frank Becker <[email protected]>.
/etc/zshrc
file, for reference:
#
# /etc/zshrc is sourced in interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
## shell functions
#setenv() { export $1=$2 } # csh compatibility
# Set prompts
PROMPT='[%n@%m]%~%# ' # default prompt
#RPROMPT=' %~' # prompt for right side of screen
# bindkey -v # vi key bindings
# bindkey -e # emacs key bindings
bindkey ' ' magic-space # also do history expansion on space
# Provide pathmunge for /etc/profile.d scripts
pathmunge()
{
if ! echo $PATH | /bin/grep -qE "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
_src_etc_profile_d()
{
# Make the *.sh things happier, and have possible ~/.zshenv options like
# NOMATCH ignored.
emulate -L ksh
# from bashrc, with zsh fixes
if [[ ! -o login ]]; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
fi
}
_src_etc_profile_d
This is still present on the 2016.09 PV AMI.
Anyone emailed Frank Becker fb@alien8.de?
Hi, Doing some clean up on old issues, and since I was not able to reproduce this I'm assuming it is no longer a problem.
But do let me know if anyone is still facing this issue.
And if I closed this too soon feel free to open a new one, it will make tracking it easier too.
I believe this was fixed some time in 2017: https://github.com/ohmyzsh/ohmyzsh/issues/4771#issuecomment-300939290. Thanks for asking!
Most helpful comment
This is still present on the 2016.09 PV AMI.