tartansandal / conda-bash-completion

Bash completion support for conda
GNU General Public License v3.0
152 stars 7 forks source link

/etc/profile.d/bash_completion.sh: No such file or directory #2

Closed astier closed 5 years ago

astier commented 5 years ago

Executing the following line as described in the README

source $CONDA_ROOT/etc/profile.d/bash_completion.sh

fails with the following message

/etc/profile.d/bash_completion.sh: No such file or directory

What is the correct path?

tartansandal commented 5 years ago

Thanks for the feedback @astier :smile:. I'm updated the installation instruction to be (hopefully) more clear:

CONDA_ROOT=~/anaconda3   # <- set to your Anaconda/Miniconda installation directory
source $CONDA_ROOT/etc/profile.d/bash_completion.sh

Does this make sense?

astier commented 5 years ago

I just added to my bashrc

[ -r ~/miniconda3/etc/profile.d/bash_completion.sh ] &&. ~/miniconda3/etc/profile.d/bash_completion.sh

It works. Thanks. Why do we need to set CONDA_ROOT?

tartansandal commented 5 years ago

Great that you have got it working! :smile:

I'll think about adding your file existence check, though this is an edge case -- if it gets too convoluted, then its not the right approach.

Setting CONDA_ROOT was the simplest way I could think of to explain what needed to be done. My other attempts at explaining this where much more convoluted. (If you can think of some alternatives, please, let me know).

Technically, CONDA_ROOT corresponds to the CONDA_PREFIX of the CONDA_DEFAULT_ENV environment, although it is not explicitly defined (I think it should be). You could get there with:

CONDA_ROOT = $(dirname $(dirname $CONDA_EXE)))

but that does not work on all platforms and setups, especially if you install the package into another environment. Ah well. Such is the tyranny of systems programming.

astier commented 5 years ago

Isn't the file-check required when conda-bash-completion is not installed?

tartansandal commented 5 years ago

Isn't the file-check required when conda-bash-completion is not installed?

If that's the case, then you would be doing a manual installation, with the bash-completion library installed and loaded independently. But then you don't need to add anything to your .bashrc file.

I'll make the two installation methods more explicit.

There might be a case where you:

  1. Install conda-bash-completion and bash-completion as a dependency
  2. Modify your .bashrc
  3. Uninstall conda-bash-completion
  4. Now bash initialisation raises an error

So protecting against this is reasonable. Thanks for the feedback on this :smile:

astier commented 5 years ago

I am checking if the file exists because if I make a fresh linux-install I pull my dotfiles with the bashrc which tries to source the conda-completion-file but would fail because I usually don't install conda right away.