Description
Virtualenv uses shebang parsing of the home_dir path. That is, it creates files (e.g. bin/pip
) which begin with:
#!"/path/to/home/dir/bin/python3.6"
The #!
is known as a shebang. The path after the shebang is parsed by the kernel on Linux and Mac OS X (though not on Windows). This kernel parsing is fragile: it can't tolerate
- whitespace in the path: see issue Whitespace in root path of virtualenv breaks scripts #53 "Whitespace in root path of virtualenv breaks scripts", Pip fails with space in virtualenv path #994 "Pip fails with space in virtualenv path"
- a path which is too long: Long env path names cause weird errors after activiting virtual environment #997 "Long env path names cause weird errors after activiting virtual environment"
- a path with emoji: see issue Not compatible with a directory having emojis in its path #1014 "Not compatible with a directory having emojis in its path"
All those issues propose various fixes. Some of the fixes involve proposing changes upstream to distutil or pip. The upstream teams are resisting some changes because they are OS-specific or fragile. It is taking time to work that out.
In the meantime I think virtualenv should check the home_dir path for any of these flaws. On Mac OS and Linux, it should fail with an error if a path has any of these problems. Maybe there should be a way to override the error if a user explicitly asks to.
This issue is for the adding of a warning message to virtualenv, to reduce the impact of fragile shebang parsing until the above underlying issues are fixed, somehow.
It seems to me that adding this warning message should be a logically simple fix to virtualenv/virtualenv.py
. Around line 685:688, next to the check for os.path.exists(home_dir)
, add a similar check for is_valid(home_dir)
. Function is_valid()
checks for all the fragilities exposed by the above issues.
The warning message could alternatively be a fatal error message. If so, then having an option like -f
to override the error might also be a good addition.