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

Missing (any python version causes venv not be created #1898

Closed
scop opened this issue Apr 13, 2024 · 4 comments
Closed

Missing (any python version causes venv not be created #1898

scop opened this issue Apr 13, 2024 · 4 comments
Labels

Comments

@scop
Copy link
Contributor

scop commented Apr 13, 2024

[tools]
python = [
   "3.12",
   "3.13-dev",
   "3.10",
]
[env]
_.python.venv = { path = "venv", create = true }

With this config, if venv does not exist and any of the Python versions specified in the config are missing, the resulting error and behavior when cding to the dir is (using 3.10 missing as the example)

mise no venv found at: .../venv

To create a virtualenv manually, run:
python -m venv .../venv
mise missing: python@3.10

In combination with #1897, this seems a bit odd given that the missing version here would not even be the version with which the venv would be created.

Further, when not cd'ing to the dir but just hitting enter in it (bash integration), the error message is the same except the last mise missing: ... line is not output. This got me quite confused because it was the scenario where I hit the issue in, and I did not know that one of the python versions was missing.

Maybe either output the "mise missing: ..." also when just hitting the enter and not cd'ing, and/or not bother with missing python versions regarding venv creation in case the venv would not be created or activated with the missing version?

mise version 2024.4.4 linux-x64 (37b44e2 2024-04-11)

@ocervell
Copy link

Agree, this also blocks a normal ls command so it is a weird behavior.

@jdx jdx added the python label Dec 11, 2024
@syhol
Copy link
Contributor

syhol commented Dec 14, 2024

The "no venv" warning

this also blocks a normal ls command

It doesn't block anything, it just print the warning before every shell prompt inside the directory, which I think is a really good thing.

Further, when not cd'ing to the dir but just hitting enter in it (bash integration), the error message is the same except the last mise missing: ... line is not output. This got me quite confused because it was the scenario where I hit the issue in, and I did not know that one of the python versions was missing.

I think this is a great point and should be addressed.
Today the warning is fine when create = false or create is not set. But when create = true is set, it should have better instructions on what is wrong and what should be done to resolve it. My proposal is:

mise WARN  no venv found at: .../venv
mise will automatically create the venv once all requested python versions are installed.
To install the missing python tools and create the venv, please run:
mise install

I don't think we should change the behaviour of the existing mise missing: python@3.10 warning because thats part of the status.missing_tools setting.

Only block venv creation when missing the required python version.

In combination with #1897, this seems a bit odd given that the missing version here would not even be the version with which the venv would be created.

I don't think its a big deal that mise checks all python versions. Perhaps mise could check if the required version (first or env._.python.venv.python) is missing, but that might be a little tricky because it currently iterates over the list of missing tools and checks if any are python.

if ts
    .list_missing_versions()
    .iter()
    .any(|tv| tv.ba().tool_name == "python") 
{
    // ...
}

So it would need a bit of rework. So I would say this is a nice to have enhancement, but not a bug.

Next steps

  1. I'll create a PR for new warning when create is true
  2. I'll create a new issue to only check the required python version

@syhol
Copy link
Contributor

syhol commented Dec 15, 2024

PR for new warning: #3573

@syhol
Copy link
Contributor

syhol commented Dec 15, 2024

I think we can close this ticket now. Warning is merged and the enhancement is split into a new ticket.

@jdx jdx closed this as completed Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants