Completions from completion-module are not working in new shell. I was able to verify that they are loaded by putting just a simple echo into the init.sh of the module.
When i type vagrant and push tab:
~ ❯ vavagrant
-- gem subcommand --
--version -- Prints the Vagrant version information
box -- Box commands
connect -- Connects to a shared, remote Vagrant environment
destroy -- Destroys the vagrant environment
docker-logs -- Shows Docker logs
docker-run -- Run one-off commands against a Docker container
global-status -- Reports the status of all active Vagrant environments on the system
halt -- Halts the currently running vagrant environment
[...]
When i type vagrant and push tab:
.zprezto ❯ vagrant
-- file --
CONTRIBUTING.md LICENSE README.md init.zsh modules/ runcoms/
Add a new user and freshly install zprezto...
~ ❯ echo $USER
dakr
~ ❯ sudo -i -u testuser
~ ❯ echo $USER
testuser
~ ❯ grep -B8 "'completion'" .zpreztorc
zstyle ':prezto:load' pmodule \
'environment' \
'terminal' \
'editor' \
'history' \
'directory' \
'spectrum' \
'utility' \
'completion' \
~ ❯ grep -H vagrant .zcompdump*
~ ❯ source .zprezto/modules/completion/init.zsh
~ ❯ grep vagrant .zcompdump*
~ ❯ rm -rf .zcompdump*
~ ❯ source .zprezto/modules/completion/init.zsh
~ ❯ grep vagrant .zcompdump*
'vagrant' '_vagrant'
_trash-restore _udisksctl _ufw _vagrant _virsh \
_ufw _vagrant _virsh _virtualbox _vnstat \
~ ❯ exit
Good morning! And in case I don't see ya, good afternoon, good evening and goodnight.
--Truman Burbank
~ ❯ echo $USER
dakr
~ ❯ sudo -i -u testuser
~ ❯ echo $USER
testuser
~ ❯ grep vagrant .zcompdump*
~ ❯ echo 'echo "is loaded"' >> .zprezto/modules/completion/init.zsh
~ ❯ exit
So long and thanks for all the fish.
-- Douglas Adams
~ ❯ sudo -i -u testuser
is loaded
~ ❯
Update:
I found the source of my Problems:
```~ ❯ tail -n 7 /etc/zsh/zshrc
if [[ -z "$skip_global_compinit" ]]; then
autoload -U compinit
compinit
fi
```
So all i had to do is:
echo 'export skip_global_compinit=1' >> ~./.zprofile
Oof this is a bit weird. I'm not sure the best way to solve this since I'd rather not add that export to the prezto runcoms...
Ups totally forgot where this condition is from. It's from /etc/zsh/zshrc in Ubuntu 18.04.
So yes, it's pretty distri specific. So maybe just close and hope everyone will find it by themself?
I'll leave this open for now - it may be worth adding anyway, especially if it's in Ubuntu since it's so commonly used.
Does this affect git completions? I am having an issue with git add completing with
-- not a git repository --
even inside git repositories. Doing the above does not fix the issue, but this issue seems close enough to my problem that I wanted to check.
I bump into a similar problem. in Opensuse 15.0 /etc/zshrc (from package zsh) there is
autoload -U compinit
compinit
in modules/completion/init.zsh there is
if (( $#_comp_files )); then
compinit -i -C
else
compinit -i
fi
compinit -i -C doesn't seem to load new _function in $fpath, I had to compinit again.
I hope this helps.
Could tab completion no working be caused by users permissions and compaudit?
I ran into a a similar problem with a fresh install. I eventually discover that replacing the .zcompdump created after install with the old one, would make tab completion work again. But now I receive a zsh compinit: insecure directories, run compaudit for list error when starting the Terminal.
Running compaudit show the culprit is my non default /usr/local/Cellar/zsh/ and /usr/local/share/zsh/ permissions. Basically the whole usr/local tree belongs to the group staff and has 2775 permissions set.
To silence the warnings I ran:
sudo find /usr/local/Cellar/zsh/ -type d -exec chmod 2755 {} \;
sudo find /usr/local/share/zsh/ -type d -exec chmod 2755 {} \;
Everything works fine now and erasing and reinstalling prezto won't cause any issues.
It seems that the whole problem was caused by the non-default permissions, but the big problem was the lack of clues about what was wrong. Instead of causing an error or raising a warning, tab completions was silently failing. Maybe a permissions checking would be in order?
In Ubuntu 18.10, I "fixed" this by doing:
# disable default behavior in /etc/zsh/zshrc
echo 'export skip_global_compinit=1' >> ~/.zprofile
echo autoload -U compinit >> ~/.zshrc
echo compinit >> ~/.zshrc
My command-specific tab-completions work now.
Im mint 19 I used @stealthybox fix but I added -C to the compinit instruction to avoid long start time
@burgesQ using compinit -C definitely starts faster, but it breaks command completion for me. I'm not educated as to why.
but it breaks command completion for me
In the end I've struggled the same error once I rebooted my pc (& so maybe my zsh session ?). The first fix I found was to manually run a compinit at boot. Then the compinit -C in my zshrc was then loading the new cache file for each new shell.
After some digging I found some interesting stuff here, and after cleaning the old caches files the completion (& my startup time) worked back like a charm.
So in then end I had to :
export skip_global_compinit=1' to.zprofile`rm -rf ~/.zcomp{cache,file}*zshrc) : # fix completion not working
# https://gist.github.com/ctechols/ca1035271ad134841284
autoload -Uz compinit
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
compinit;
else
compinit -C;
fi;
@burgesQ acutally this is already done by the completion module:
https://github.com/sorin-ionescu/prezto/blob/master/modules/completion/init.zsh#L35-L41
Quick question:
Is it required to delete the ~/.zcompdump in order to get new completions to work after updating the completion submodule?
Hoping there's a better story here if so. I spent a while trying to figure out why it wasn't working and I'm assuming that the check means that it won't load new completions until 20h have passed.
I'm not sure if this is what was happening, but maybe we can add a note to the completion readme if so?
Most helpful comment
Update:
I found the source of my Problems:
```~ ❯ tail -n 7 /etc/zsh/zshrc
If you don't want compinit called here, place the line
skip_global_compinit=1
in your $ZDOTDIR/.zshenv or $ZDOTDIR/.zprofile
if [[ -z "$skip_global_compinit" ]]; then
autoload -U compinit
compinit
fi
```
So all i had to do is:
echo 'export skip_global_compinit=1' >> ~./.zprofile