Skip to content

Cygwin and msys2 bash activator compatibility #1940

Closed
@yilei

Description

@yilei

Issue

Run the following via msys2:

$ /c/Users/builder/AppData/Local/Programs/Python/Python39/Scripts/virtualenv.exe --no-pip --no-setuptools --no-wheel -p /c/Users/builder/AppData/Local/Programs/Python/Python39/python.exe /tmp/tmp.uw7eZfvJIO
$ source /tmp/tmp.uw7eZfvJIO/Scripts/activate
$ python
python: command not found

The content of /tmp/tmp.uw7eZfvJIO/Scripts/activate contains VIRTUAL_ENV='C:\tools\msys64\tmp\tmp.uw7eZfvJIO', but it's expected to be VIRTUAL_ENV='/c/tools/msys64/tmp/tmp.uw7eZfvJIO', thus it can't locate python.

I believe the legacy version handles this correctly here:

virtualenv/virtualenv.py

Lines 1742 to 1748 in 4c9899f

home_dir_msys = (drive and "/{}{}" or "{}{}").format(drive[:1], tail)
# Run-time conditional enables (basic) Cygwin compatibility
home_dir_sh = """$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u '{}'; else echo '{}'; fi;)""".format(
home_dir, home_dir_msys
)
files["activate"] = ACTIVATE_SH.replace("__VIRTUAL_ENV__", home_dir_sh)

which contains:

VIRTUAL_ENV="$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u 'C:\tools\msys64\tmp\tmp.uw7eZfvJIO'; else echo '/C/tools/msys64/tmp/tmp.uw7eZfvJIO'; fi;)"

Environment

Provide at least:

  • OS: Windows 7, using msys2 v20200903.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions