Closed hongyi-zhao closed 4 years ago
Hi @hongyi-zhao,
In short, this completion code only supports the conda
command.
The conda
command is for managing local Anaconda/Miniconda installations and package sets.
This is a core component that is always installed.
The anaconda
command is for managing Anaconda Cloud accounts and the packages stored there.
This is an additional component that is only optionally installed.
These are two separate commands with different code bases. They would need separate completion implementations.
Of course this project could serve as a template for anyone wanting to write completion code for the anaconda
command. :-)
Thanks for your notes.
But, I also noticed that the current implementation of your code cannot do the sub-command' arg completions. Say, for the following:
$ conda config <tab>
It will do nothing for completions. In my mind, the completions should be trigged in any level for sub-commands. Any hints for this issue?
Regards
Try:
$ conda config --<tab>
the config
sub-command is odd in that it only takes option arguments, whereas say, the env
sub-command takes both options and arguments. We have to insist on at least one dash -
to get consistent behaviour.
Hope this helps.
It cann't solve the problem with your suggestion:
$ conda config --<tab>
Then I get the following:
$ conda config --bash: conda config: syntax error in expression (error token is "config")
Damn. That is a bug I thought I had squashed :disappointed:
Try the following to reset the completion cache.
$ unset __comp_conda_cache
Still failed:
$ unset __comp_conda_cache
$ conda config --<tab>
$ conda config --bash: conda config: syntax error in expression (error token is "config")
$
ps. I use the follwong anaconda python with pyenv:
$ conda info
active environment : base
active env location : /home/werner/.pyenv/versions/anaconda3-4.3.0
shell level : 0
user config file : /home/werner/.condarc
populated config files : /home/werner/.condarc
conda version : 4.8.0
conda-build version : not installed
python version : 3.6.0.final.0
virtual packages : __glibc=2.30
base environment : /home/werner/.pyenv/versions/anaconda3-4.3.0 (writable)
channel URLs : https://conda.anaconda.org/anaconda-fusion/linux-64
https://conda.anaconda.org/anaconda-fusion/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
package cache : /home/werner/.pyenv/versions/anaconda3-4.3.0/pkgs
/home/werner/.conda/pkgs
envs directories : /home/werner/.pyenv/versions/anaconda3-4.3.0/envs
/home/werner/.conda/envs
platform : linux-64
user-agent : conda/4.8.0 requests/2.22.0 CPython/3.6.0 Linux/5.3.0-24-generic ubuntu/19.10 glibc/2.30
UID:GID : 1000:1000
netrc file : /home/werner/.netrc
offline mode : False
Thanks that. I might not be able to get back to that until tomorrow, however, I am very keen to figure out what is going wrong and help you out.
Thanks a lot, I'm very grad to find the bug and let this tool more perfect, and convenient for users like me.
Ah I thought that bug looked old.
While tracking this down, I discovered that the new conda
release that you are using (4.8.0) contains my older completion code. This has known bugs and was hardwired into the init bash
process rather than being packaged. I will get in touch with the maintainers to to see if I can get it removed ASAP.
Until then, you can try to force the loading of the new improved code with:
source /home/werner/.pyenv/versions/anaconda3-4.3.0/share/bash-completion/completions/conda
Hope this helps.
Thanks, I'll try it.
Ah I thought that bug looked old.
While tracking this down, I discovered that the new
conda
release that you are using (4.8.0) contains my older completion code. This has known bugs and was hardwired into theinit bash
process rather than being packaged. I will get in touch with the maintainers to to see if I can get it removed ASAP.Until then, you can try to force the loading of the new improved code with:
source /home/werner/.pyenv/versions/anaconda3-4.3.0/share/bash-completion/completions/conda
To install the latest git version of this package, the following command is enough or not:
conda install -c tartansandal conda-bash-completion
Hope this helps.
That should work. The same package is now available from conda-forge so the following will also work:
conda install -c conda-forge conda-bash-completion
The long-term plan is to make one of the base packages, so at some point in the future, it will be installed by default.
I've learned that the conda-forge is based on several continuous integration tools and can auto build the latest sources from the corresponding repository.
But, whether the following two commands will always obtain the same version:
$ conda install -c tartansandal conda-bash-completion $ conda install -c conda-forge conda-bash-completion
What's the difference between the above two commands?
From the manpage of conda install, it said that:
-c CHANNEL, --channel CHANNEL
Additional channel to search for packages. These are
URLs searched in the order they are given (including
file:// for local directories). Then, the defaults or
channels from .condarc are searched (unless
--override-channels is given). You can use 'defaults'
to get the default packages for conda. You can also
use any name and the .condarc channel_alias value will
be prepended. The default channel_alias is
http://conda.anaconda.org/.
From the above description, I can easily understand that the conda-forge is a channel name. But do you mean tartansandal is a channel name too?
Regards
You are 100% correct that 'tartansandal' is a channel name too. Individual users can host there own channels on Anaconda Cloud, e.g., https://anaconda.org/tartansandal. That was my initial attempt at distributing the code and learning how to write conda 'recipes'. Later, this was accepted into conda-forge
-- a somewhat convoluted process. Some versions have been published to both channels. New versions will now only be published to conda-forge
. The old packages only exist for historical consistency.
Also note that the conda developers have been made aware of the issue with the 4.8.0 release that your issue has brought to light (see )https://github.com/conda/conda/pull/9421#issuecomment-567508980). Thank you very much for taking the time to report it! A new release is being built, but it may take some time for it to surface. I don't really know how long that will be.
Closing this issue since it will be resolved by the upcoming patch release of conda
and there is a temporary workaround.
Hi,
I tried this tool, it seems it works smoothly with conda, while not works with anaconda.
Any hints?