Skip to content

uv venv's activate command cannot work on MSYS2 #4984

Description

@pplmx

Steps to Reproduce

At MSYS2, run the following command:

❯ uv venv
Using Python 3.12.4 interpreter at: C:\Users\xxx\AppData\Local\Programs\Python\Python312\python.exe
Creating virtualenv at: .venv
Activate with: source .venv\Scripts\activate
❯ source .venv\Scripts\activate
source: no such file or directory: .venvScriptsactivate

Suggested Fix

Use the correct path to activate the virtual environment:

source .venv/Scripts/activate

Environment Details

cat /etc/os-release
NAME=MSYS2
ID=msys2
PRETTY_NAME="MSYS2"
ID_LIKE="cygwin arch"
HOME_URL="https://www.msys2.org"
BUG_REPORT_URL="https://github.com/msys2/MSYS2-packages/issues"

uv version
uv 0.2.24 (527b711bc 2024-07-10)

Activity

  1. zanieb commented on Jul 11, 2024

    @zanieb
    Member

    Thanks! Looks like we need to display a posix style path here, it should be relatively easy to fix?

  2. zanieb commented on Jul 11, 2024

    @zanieb
    Member

    Considering something like

    diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs
    index cb906898..7e669ead 100644
    --- a/crates/uv/src/commands/venv.rs
    +++ b/crates/uv/src/commands/venv.rs
    @@ -312,7 +312,7 @@ async fn venv_impl(
     /// Quote a path, if necessary, for safe use in a POSIX-compatible shell command.
     fn shlex_posix(executable: impl AsRef<Path>) -> String {
         // Convert to a display path.
    -    let executable = executable.as_ref().user_display().to_string();
    +    let executable = executable.as_ref().portable_display().to_string();
     
         // Like Python's `shlex.quote`:
         // > Use single quotes, and put single quotes into double quotes

    but I'm a little confused that portable_display() only uses portable slashes for relative paths? We might need another helper method that always uses the portable path? We'll want to add some tests if we can.

  3. pplmx commented on Jul 11, 2024

    @pplmx
    Author

    Thanks! Looks like we need to display a posix style path here, it should be relatively easy to fix?

    Yes, if msys2 is found, directly printing a POSIX-style path is fine.

  4. MathiasAugustesen commented on Aug 20, 2024

    @MathiasAugustesen

    Is this one still up for grabs? If so I'd like to take a stab at it

  5. zanieb commented on Aug 20, 2024

    @zanieb
    Member

    I think I might have fixed this

  6. zanieb commented on Aug 20, 2024

    @zanieb
    Member

    Yeah, #5956 — sorry.

  7. MathiasAugustesen commented on Aug 20, 2024

    @MathiasAugustesen

    No problem, I'll look around for something else to tackle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions