Skip to content
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

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

Closed
pplmx opened this issue Jul 11, 2024 · 7 comments
Closed

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

pplmx opened this issue Jul 11, 2024 · 7 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@pplmx
Copy link

pplmx commented Jul 11, 2024

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)
@zanieb
Copy link
Member

zanieb commented Jul 11, 2024

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

@zanieb zanieb added bug Something isn't working good first issue Good for newcomers labels Jul 11, 2024
@zanieb
Copy link
Member

zanieb commented Jul 11, 2024

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.

@pplmx
Copy link
Author

pplmx commented Jul 11, 2024

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.

@MathiasAugustesen
Copy link

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

@zanieb
Copy link
Member

zanieb commented Aug 20, 2024

I think I might have fixed this

@zanieb
Copy link
Member

zanieb commented Aug 20, 2024

Yeah, #5956 — sorry.

@zanieb zanieb closed this as completed Aug 20, 2024
@MathiasAugustesen
Copy link

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
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants