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

fix(python): check only if first or specified python is installed for _.venv #3576

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/config/env_directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use heck::ToKebabCase;
use indexmap::IndexMap;
use serde::{Deserialize, Deserializer};

use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::config_file::{config_root, trust_check};
use crate::config::{Config, SETTINGS};
Expand All @@ -17,7 +18,7 @@ use crate::file::{display_path, which_non_pristine};
use crate::plugins::vfox_plugin::VfoxPlugin;
use crate::tera::{get_tera, BASE_CONTEXT};
use crate::toolset::ToolsetBuilder;
use crate::{dirs, env};
use crate::{backend, dirs, env};

#[derive(Debug, Clone)]
pub enum PathEntry {
Expand Down Expand Up @@ -290,11 +291,27 @@ impl EnvResults {
.into_iter()
.chain(env::split_paths(&env_vars[&*PATH_KEY]))
.collect::<Vec<_>>();
let missing = ts
.list_missing_versions()
.iter()
.any(|tv| tv.ba().tool_name == "python");
if missing {
let ba = BackendArg::from("python");
let installed = ts
.versions
.get(&ba)
.and_then(|tv| {
// if a python version is specified, check if that version is installed
// otherwise use the first since that's what `python3` will refer to
if let Some(v) = &python {
tv.versions.iter().find(|t| t.version.starts_with(v))
} else {
tv.versions.first()
}
})
.map(|tv| {
let backend = backend::get(&ba).unwrap();
backend.is_version_installed(tv, false)
})
// if no version is specified, we're assuming python3 is provided outside of mise
// so return "true" here
.unwrap_or(true);
if !installed {
warn!(
"no venv found at: {p}\n\n\
mise will automatically create the venv once all requested python versions are installed.\n\
Expand Down
Loading