I think this is new since I just updated fish shell and it was the first thing I noticed that was broken. The $PATH upon using pipenv shell seems to put previous $PATH then virtualenv path then $PATH again, but I am not entirely sure. I believe it used to be work fine out of the box with just prepending the virtualenv PATH to my $PATH but after my fish_user_path (which also was not preferable)
Have pipenv prepend virtualenv to path in fish shell
Has virtualenv python path in between two copies of $PATH for some reason
Update to fish 3.0
Other:
Yeah I rolled back fish to 2.7.1 (if anyone has this issue, try brew switch fish 2.7.1
) and seems to work. Think its specific to pipenv prepending to path. Also have issues with pipenv prepending to $PATH after $PATH but before the $fish_user_paths stuff so maybe could be done as one fix?
I spent a lot of time on this problem and my conclusion is the same as @grahamannett .
Yeah on Fish 3.0 it does not work......
On bash and fish 2, it works fine!
I'm using macOS Mojave with fish
Unfortunately, I don't know how to roll back to my fish version(in my mac no old binary)
Currently facing the same issue. I actually posted to https://superuser.com/questions/1396889/fish-shell-virtualenv-path-not-prepended-to-path with details of the problems before discovering this issue.
I think I may have created a patch but Im not sure if it will break previous fish versions at this point.
I've just come across https://github.com/fish-shell/fish-shell/issues/5456 which seems to me to be causing this issue with pipenv. There are a couple of workarounds there but not fix yet.
~I think I may be of some assistance.~ Nope they are already working on a fix for this in fish.
I'm using fish 3 and my paths are broken as well!
For anyone that finds this issue.
brew unlink fish
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/2827b020c3366ea93566a344167ba62388c16c7d/Formula/fish.rb
This will install version 2.7.1 of fish.
from https://github.com/fish-shell/fish-shell/issues/5456#issuecomment-451697811:
The problem is that you are directly manipulating PATH, which makes it hard for fish to know what's the originally exported PATH, what is fish's customized view of PATH, and what the correct order of PATH entries is.
i.e. using set -gx PATH
and expecting it to be inherited in the correct order is not going to work, and you should look at using a workaround like the ones proposed.
So, if you are using fish as a login shell, you can resolve this (or at least have fish prepend pyenv's paths) by using the following:
if status --is-login
set -g fish_user_paths ~/.pyenv/shims fish_user_paths
end
And if you only use fish as an interactive shell, you can use this fix in your fish config:
if not contains ~/.pyenv/shims $fish_user_paths
set -g fish_user_paths ~/.pyenv/shims $fish_user_paths
end
I'm going to close this as it's a fish issue and there are several workarounds plus a fix lined up for the next minor release of fish. Thanks for the report!
i know this is closed but it still seems quite broken for me at the least and only related to pipenv shell
with fish 3.0.
Using source /Users/graham/.local/share/virtualenvs/example_virtual_env/bin/activate.fish
works (it places the virtualenv python path in front of everything for my path where as using pipenv shell
places the virtualenv python path after everything but before $fish_user_paths
I don't think this is a fish problem as I am using a fresh install and have nothing impacting my path besides stuff in /etc/paths
Edit: Weird. Probably I was wrong. Was writing a function to just source the file for me and testing something out and it magically started working. For anyone having an issue, try changing fish from login to interactive then back to login or leave as interactive?
Otherwise can try something like this (but it doesn't launch in subshell)
function pipenvshell
# activate may mess up prompt with 2 virtualenvs
if set -q VIRTUAL_ENV_DISABLE_PROMPT
echo "Using Previous VIRTUAL_ENV_DISABLE_PROMPT"
else
set -l VIRTUAL_ENV_DISABLE_PROMPT 1
end
set -l _curr_wd (basename $PWD)
source $HOME/.local/share/virtualenvs/$_curr_wd*/bin/activate.fish
end
Most helpful comment
For anyone that finds this issue.
This will install version 2.7.1 of fish.