Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl+C exits poetry shell in Fish shell #823

Closed
2 tasks done
jhrmnn opened this issue Jan 22, 2019 · 4 comments
Closed
2 tasks done

Ctrl+C exits poetry shell in Fish shell #823

jhrmnn opened this issue Jan 22, 2019 · 4 comments

Comments

@jhrmnn
Copy link
Contributor

jhrmnn commented Jan 22, 2019

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: macOS 10.14.2
  • Poetry version: 0.12.11

Issue

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.

@johnfraney
Copy link

johnfraney commented Apr 25, 2019

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))

@actionless
Copy link

actionless commented Jun 28, 2019

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

@johnfraney
Copy link

@jhrmnn This was fixed in 1.0.0b2 by making the change I mentioned above

@jhrmnn jhrmnn closed this as completed Oct 20, 2019
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants