1

We're using fake root environment at work. Basically it is a bunch of directories which emulate apt-get and dpkg if some environment variables are set. I.e. you run apt-get install xxx and package xxx is being installed into this environment but not into the system.

When I used bash, apt-get autocomplete worked perfectly. When I typed apt-get install <Tab><Tab>, it showed me the list of local packages if I was in a fake root and the global list otherwise.

However, when I switched to zsh weird things happened. Currently only global packages show up in the list, though it was not always the case. Here is the complete story.

  1. I install Ubuntu and setup the fake root and zsh.
  2. I reinstall Ubuntu from scratch, saving /home which was on a separate partition.
  3. Now zsh autocomplete always show me the packages from the fake root, regardless whether I have the env vars set.
  4. I reinstall zsh and zsh-common. Now completion always work as no fake root exist. At the same moment I realize that after reinstall the folder Ubuntu disappeared from /usr/share/zsh/functions/Completion, now apt-get completion rules are taken from Debian folder.

Could you please explain me what could happen here and how can I setup zsh completion work with both system and fake apt-get?

I use Ubuntu 16.04.2.

P.S. My fake root is not related to fakeroot command.

1

Well, I have finally figured it out. Zsh completion engine caches several things, including the list of available packages returned by apt. Now my story seems clear: when autocomplete always suggested me packages from the fake root it was because first time I ran zsh in the fake root environment and the corresponding package list got into a cache.

If you want to override it (assuming you use oh-my-zsh) just add the following code into your .zshrc before calling oh-my-zsh:

if [[ check for fakeroot ]]; then
  export ZSH_CACHE_DIR=desired-cache-dir-name
fi

This separates completion caching between fake root and the base system and solves the problem from the post.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.