Skip to content

Instantly share code, notes, and snippets.

@ralexx
Last active February 26, 2018 06:55
Show Gist options
  • Save ralexx/8897c4060ad57cd31ea7f8b7e0ef4218 to your computer and use it in GitHub Desktop.
Save ralexx/8897c4060ad57cd31ea7f8b7e0ef4218 to your computer and use it in GitHub Desktop.
Fixing conda's fish wrapper (as of conda v4.4.10)

Problem

After updating conda to version 4.4.x, the fish shell wrapper intended to define a conda function that knows the path of the conda executable and calls it regardless of whether the Anaconda/Miniconda installation is in $PATH. For me, this fails with

⋊> ~ conda activate base
fish: Unknown command 'shell.fish'
- (line 1):
begin; shell.fish activate base
       ^
from sourcing file -
	called on line 60 of file /usr/local/Cellar/fish/2.7.1/share/fish/functions/eval.fish

in function 'eval'
	called on line 67 of file /usr/local/share/anaconda/etc/fish/conf.d/conda.fish

in command substitution
	called on line 65 of file /usr/local/share/anaconda/etc/fish/conf.d/conda.fish

in function 'conda'
	called on standard input
	with parameter list 'activate base'

Solution

Insert -g before the path variables for the conda executable and its root directory are defined

set -g _CONDA_EXE "[/your/path/to/anaconda]/bin/conda"
set -g _CONDA_ROOT "[/your/path/to/anaconda]"

Details

The standard conda installation installs its fish wrapper as follows (from /conda/utils/functions.sh):

mkdir -p "$prefix/etc/fish/conf.d/"
rm -f "$prefix/etc/fish/conf.d/conda.fish"
echo "set _CONDA_EXE \"$conda_exe\"" > "$prefix/etc/fish/conf.d/conda.fish"
echo "set _CONDA_ROOT \"$prefix\"" >> "$prefix/etc/fish/conf.d/conda.fish"
cat "$src_dir/conda/shell/etc/fish/conf.d/conda.fish" >> "$prefix/etc/fish/conf.d/conda.fish"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment