-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Long env path names cause weird errors after activiting virtual environment #997
Comments
Not virtualenv's fault. Shebangs have length limits, see http://www.in-ulm.de/~mascheck/various/shebang/. This is basically a duplicate of #994 - virtualenv are broken with fragile kernel shebang parsing. |
Where is the shebang written to file? And is there maybe some workaround we could employ to make virtual environments more sturdy? |
Do you mean the location of the shebang or the codes that generate a shebang? 1. In the first line of the file
I don't think there are simple workarounds. A possibility is writing a user space shebang parser just like py.exe on Windows. |
Using pip as an example, one thing we could do is move the current
Basically, wrap each program in a shell script calling the original file, passing on all of its arguments. That will get around the problem of long shebangs. And if we quote these paths in Bash we could probably solve the problem with space characters in paths as well. |
OK maybe my definition for "workarounds" is too strict. I thought it shouldn't break existing things. In this case, using /bin/bash usually works but not always. Some systems do not install bash in /bin/ (FreeBSD install it at /usr/local/bin/bash), and some systems do not provide bash at all. (Most Android uses /system/bin/sh) A similar idea was proposed 3 years ago: pypa/pip#923 (comment). Apparently no PyPA core developers are interested in this approach :( |
No, you're right. The workaround shouldn't break things. As long as
It's nice to see that someone else brought up the same idea. However, @cellularmitosis phrased it in negative terms back then, so it only makes sense that no one took it seriously. It doesn't seem like any of the developers actually commented on it. Let us give it a positive spin this time around and present it as waterproof solution to long paths and spaces. I'm not exactly sure how I would go about to putting this in the virtualenv source code though. |
Looks better. If it's possible to use a single file, I believe it will be ready for a pull request! |
@yan12125 I created a pull request. |
I've updated |
@HaraldNordgren ah, I should have been clearer that my dismay was directed at Apple, not at the virtualenv guys! On Linux, this isn't an issue at all, and I had assumed this was an insurmountable shortcoming of OS X shebang parsing. Glad to see there's a solution! |
Is it really fixed? |
It seems here we've regressed as we're not using |
Hello, a fix for this issue has been released via virtualenv 20.0.2; see https://pypi.org/project/virtualenv/20.0.2/ (https://virtualenv.pypa.io/en/latest/changelog.html#v20-0-2-2020-02-11) . Please give a try and report back if your issue has not been addressed; if not, please comment here, and we'll reopen the ticket. We want to apologize for the inconvenience this has caused you and say thanks for having patience while we resolve the unexpected bugs with this new major release. |
Thank you for acting quick! |
Well instead of pip... you can use python -m pip. That helped me |
@MartinKosicky you can, but should no longer be needed. |
Ok I am a bit confused. I am using venv probabbly and that is why I can't see this fix. This is virtualenv, which is something else? |
Yeah, we're very much different from venv. One advantage of using virtualenv is that we can fix issues faster than venv. There's more detail on differences here #1366 (comment) |
very hard to google something about virtualenv because it always gives me venv... even the standard python pages call it virtualenv, but the module is called venv :D |
IMHO it should be calling it virtual environments, not virtualenv. If you find virtualenv in venv doc then probably open an issue under http://bugs.python.org/ |
After creating a virtualenv in the path
/home/harald/git-repos/sandbox/stackoverflow/41454203-how-do-you-import-the-library-being-tested-when-running-a-nosetest/env
I could not run the env's pip,
and running just pip gives me the system's pip, with all of its packages.
The text was updated successfully, but these errors were encountered: