Skip to content

mise: drop global python, add venv auto-activation + idiomatic version files#17

Merged
tyvsmith merged 1 commit into
mainfrom
mise-shims-python-venv
Jun 28, 2026
Merged

mise: drop global python, add venv auto-activation + idiomatic version files#17
tyvsmith merged 1 commit into
mainfrom
mise-shims-python-venv

Conversation

@tyvsmith

@tyvsmith tyvsmith commented Jun 28, 2026

Copy link
Copy Markdown
Owner

What

Captures the mise + fish changes from a debugging session on the CachyOS desktop.

Why

Global python = "latest" in mise put the shims dir's python ahead of /usr/bin, so GUI apps with #!/usr/bin/env python3 (e.g. virt-manager) loaded mise's python and crashed with ModuleNotFoundError: No module named 'gi'. Key insight: mise shims fall through to the next binary on PATH when a tool isn't configured, so simply dropping global python makes python3 resolve to /usr/bin/python3 everywhere by default — no need to abandon shims.

Changes

  • mise/config.toml.tmpl
    • Remove global python → system/packaged apps get /usr/bin/python3 (with gi); projects opt in via .mise.toml / idiomatic version files.
    • idiomatic_version_file_enable_tools = [node, python, go, ruby, java, rust] → cd-ing into a repo that pins a toolchain via its native version file auto-selects it through the shims, no mise.toml needed:
      • node .nvmrc / .node-version, python .python-version, go .go-version, ruby .ruby-version, java .java-version, rust rust-toolchain.toml.
      • (bun has no idiomatic version file. This honors version pins only — not dependency manifests like go.mod, package.json engines, Cargo.toml, or pyproject.toml.)
  • fish/functions/__auto_venv.fish (new) + call in fish/conf.d/zz_03_interactive.fish
    • Auto-activate the nearest .venv on cd, deactivate on leaving its tree; respects manually-activated venvs.
    • Needed because we run mise --shims, which don't fire mise's cd hook — so this owns all interactive venv activation (uv and non-uv repos). Adds ~0.1 ms startup / <0.2 ms per cd (measured) vs ~6 ms/cd for the hook approach.

Verification

  • Rendered template is byte-identical to the live ~/.config/mise/config.toml.
  • python3/usr/bin/python3 outside projects (import gi works); virt-manager launches.
  • Interactive fish still resolves mise node/go/java; .venv repos auto-activate (uv and non-uv); leaving deactivates.
  • Native pin files resolve per-repo for all six tools (e.g. .nvmrc→node, .java-version→java 21, rust-toolchain.toml→rust 1.75.0) while $HOME stays on the global version.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 28, 2026 21:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the dotfiles’ mise + fish integration to avoid globally shadowing the system Python (fixing GUI apps that expect /usr/bin/python3 + system gi), while improving per-project Python workflow via idiomatic version files and automatic .venv activation in interactive fish sessions.

Changes:

  • Remove global mise python = "latest" and document the rationale to ensure system Python is the default outside projects.
  • Enable mise idiomatic version files for common runtimes and auto-source uv venvs when applicable.
  • Add a fish cd-driven .venv auto-activation function and wire it into interactive startup.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
dot_config/mise/config.toml.tmpl Drops global Python and configures idiomatic version files + uv venv auto-sourcing.
dot_config/fish/functions/__auto_venv.fish Implements .venv discovery/activation on directory changes in fish.
dot_config/fish/conf.d/zz_03_interactive.fish Loads/registers the auto-venv behavior for interactive shells.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Autoloaded: zz_03_interactive.fish calls __auto_venv once, which loads this
# file (registering the --on-variable PWD handler) and activates the start dir.
set -l found
set -l dir $PWD
break
end
test "$dir" = / ; and break
set dir (path dirname $dir)
Comment on lines +24 to +28
if test -z "$VIRTUAL_ENV"; or set -q __auto_venv_dir
functions -q deactivate; and deactivate # swap out our previous one
source "$found/bin/activate.fish"
set -g __auto_venv_dir "$found"
end
Comment on lines +29 to +32
else if set -q __auto_venv_dir
functions -q deactivate; and deactivate
set -e __auto_venv_dir
end
{{ if contains "dev" .tags -}}
# NOTE: python intentionally NOT a global tool. mise shims fall through to the
# next binary on PATH when a tool isn't configured, so leaving python out here
# makes `python3`/`pip` resolve to /usr/bin/python3 everywhere by default —
@tyvsmith tyvsmith force-pushed the mise-shims-python-venv branch from e18c769 to 8c1d10e Compare June 28, 2026 21:59
…n files

Stops python being a global mise tool so the python shim falls through to
/usr/bin/python3 — system "#!/usr/bin/env python3" apps (paru/pacman, e.g.
virt-manager needing PyGObject/gi) work again, while terminals and projects
still get mise tools. Keeps mise on shims.

- mise/config.toml.tmpl: remove `python = "latest"`; add
  idiomatic_version_file_enable_tools = [node, python, go, ruby, java, rust]
  so cd-ing into a repo that pins a toolchain via its native file
  (.nvmrc/.node-version, .python-version, .go-version, .ruby-version,
  .java-version, rust-toolchain.toml) selects it through the shims
- fish: new __auto_venv autoload function + call in zz_03_interactive to
  auto-activate the nearest .venv on cd. Shims don't run mise's cd hook, so
  this owns all interactive venv activation (uv and non-uv repos alike)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tyvsmith tyvsmith force-pushed the mise-shims-python-venv branch from 8c1d10e to b45f755 Compare June 28, 2026 22:15
@tyvsmith tyvsmith merged commit 86f13fb into main Jun 28, 2026
1 check passed
@tyvsmith tyvsmith deleted the mise-shims-python-venv branch June 28, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants