Skip to content

No failure or warning for home_dir paths which break fragile shebang parsing #1039

Closed
@JDLH

Description

@JDLH

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions