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

Generated shebang with path to python invalid if path contains spaces #2271

Closed
peace-maker opened this issue Sep 15, 2023 · 4 comments · Fixed by #2285
Closed

Generated shebang with path to python invalid if path contains spaces #2271

peace-maker opened this issue Sep 15, 2023 · 4 comments · Fixed by #2285

Comments

@peace-maker
Copy link
Member

Creating a venv in a path with a space causes running a process in a new terminal to fail.

$ mkdir /tmp/with\ space
$ cd /tmp/with\ space
$ python -m venv venv
$ source venv/bin/activate
$ pip install pwntools
$ python pwntools/examples/attach.py

Results in generating something like this

    #!/tmp/with space/venv/bin/python
    import os
    os.execve('/usr/bin/gdb', ['/usr/bin/gdb', '-q', '/bin/bash', '8902', '-x', '/tmp/pwnrqobb6w5.gdb'], os.environ)

With the shell complaining

bash: /tmp/tmpihzr5hsv: /tmp/with: bad interpreter: No such file or directory
@Arusekk
Copy link
Member

Arusekk commented Oct 14, 2023

I think the only viable workaround would be #!/bin/env /path/with spaces/python. But I would only emit that if there are actual spaces in the path. Would you mind crafting a PR?

@Arusekk
Copy link
Member

Arusekk commented Oct 14, 2023

Or is it just virtualenv's pip's fault? :D

@peace-maker
Copy link
Member Author

Related #2285

@peace-maker
Copy link
Member Author

Fixed in #2285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants