When the Poetry shell is launched with poetry shell
under the Fish shell, Ctrl+C exits the Poetry shell. This doesn't happen when launched from Bash. I would expect that Ctrl+C does nothing. I ended up not using poetry shell
, but rather sourcing the activate.fish
from the virtual environment, but that is a bit more cumbersome, because it's not directly accessible as a Poetry command.
I can reproduce this on Arch with these versions:
poetry: 0.12.12
fish: 3.0.2
Edit: I did some digging through the Pipenv source code, and it looks like they launch a shell using os.execvp()
instead of subprocess.call()
, like Poetry. I can confirm that launching a shell that way allows fish
to accept Ctrl+C normally.
Here's a reproduction:
import os
import subprocess
SHELL_PATH = '/usr/bin/fish'
if __name__ == '__main__':
print('spawning new shell')
# Ctrl+C will kill this shell:
subprocess.call([SHELL_PATH])
# Ctrl+C will not kill this shell:
os.execvp(SHELL_PATH, ['-i'])
Here's how Pipenv launches a shell:
def _handover(cmd, args):
args = [cmd] + args
if os.name != "nt":
os.execvp(cmd, args)
else:
sys.exit(subprocess.call(args, shell=True, universal_newlines=True))
temporary workaround which i found (is not so good since it have python version hardcoded):
function poetry_shell
source $HOME/.cache/pypoetry/virtualenvs/(basename $PWD)-py3.7/bin/activate.fish
end
UPD:
or could be like that but still not fine if you have projects using non-default version:
function poetry_shell
source $HOME/.cache/pypoetry/virtualenvs/(basename $PWD)-py(python --version | grep -o '[0-9].[0-9]')/bin/activate.fish
end
@jhrmnn This was fixed in 1.0.0b2 by making the change I mentioned above
Most helpful comment
I can reproduce this on Arch with these versions:
poetry: 0.12.12
fish: 3.0.2
Edit: I did some digging through the Pipenv source code, and it looks like they launch a shell using
os.execvp()
instead ofsubprocess.call()
, like Poetry. I can confirm that launching a shell that way allowsfish
to accept Ctrl+C normally.Here's a reproduction:
Here's how Pipenv launches a shell: