mise icon indicating copy to clipboard operation
mise copied to clipboard

Python virtual env is in wrong order in PATH for nested configs

Open jdx opened this issue 10 months ago • 3 comments

Discussed in https://github.com/jdx/mise/discussions/4510

Originally posted by fredriv February 24, 2025 We're migrating to mise + uv to replace asdf + direnv.

We have a repository where various subdirectories have their own Python virtual environment. However, when setting this up in mise, the virtual environments end up in the wrong order in PATH. This seems similar to the issue reported in https://github.com/jdx/mise/discussions/4361?

In ~/tmp/base/mise.toml:

[env]
_.python.venv = { path = ".venv", create = true }

[tools]
python = "3.12.9"
uv = "0.5.29"

In ~/tmp/base/override/mise.toml:

[env]
_.python.venv = { path = ".venv", create = true }

[tools]
python = "3.13.2"
uv = "0.5.29"

When entering ~/tmp/base/override I would expect to get Python 3.13 but I'm still getting the version specified in the base config:

tmp/base/override
❯ python --version
Python 3.12.9

This is the start of the PATH variable:

tmp/base/override
❯ echo $PATH
/Users/fredriv/tmp/base/.venv/bin:/Users/fredriv/tmp/base/override/.venv/bin:...

I would expect the two entries to be in the reverse order, with my current directory's virtual environment at the start.

Output of mise doctor:

❯ mise doctor
version: 2025.2.7 macos-arm64 (2025-02-19)
activated: yes
shims_on_path: no

build_info:
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS, SELF_UPDATE
  Built: Wed, 19 Feb 2025 20:57:49 +0000
  Rust Version: rustc 1.84.1 (e71f9a9a9 2025-01-27) (Homebrew)
  Profile: release

shell:
  /bin/zsh
  zsh 5.9 (arm64-apple-darwin24.0)

dirs:
  cache: ~/Library/Caches/mise
  config: ~/.config/mise
  data: ~/.local/share/mise
  shims: ~/.local/share/mise/shims
  state: ~/.local/state/mise

config_files:
  ~/.tool-versions
  ~/.config/mise/config.toml
  ~/tmp/base/mise.toml
  ~/tmp/base/override/mise.toml

ignored_config_files: (none)

backends:
  aqua
  asdf
  cargo
  core
  dotnet
  gem
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:
  poetry    https://github.com/mise-plugins/mise-poetry.git#80d807b
  postgres  https://github.com/mise-plugins/mise-postgres.git#acbbc49

toolset:
  aqua:astral-sh/[email protected]
  aqua:hashicorp/[email protected]
  core:[email protected]

path:
  ~/tmp/base/.venv/bin
  ~/tmp/base/override/.venv/bin
  ~/.local/share/mise/installs/python/3.13.2/bin
  ~/.local/share/mise/installs/uv/0.5.29/uv-aarch64-apple-darwin
  ~/.local/share/mise/installs/terraform/1.10.4
  /opt/homebrew/share/google-cloud-sdk/bin
  /opt/homebrew/bin
  /opt/homebrew/sbin
  /usr/local/bin
  /System/Cryptexes/App/usr/bin
  /usr/bin
  /bin
  /usr/sbin
  /sbin
  /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
  /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
  /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
  /Library/Apple/usr/bin
  ~/.local/bin
  ~/.local/bin
  ~/.klipy/bin

env_vars:
  MISE_SHELL=zsh

settings:
  experimental  true ~/.config/mise/config.toml

No problems found
```</div>

jdx avatar Feb 24 '25 16:02 jdx