Skip to content

fix(python): clarify uv_venv_auto docs + prevent uv shim recursion in venv creation#8402

Merged
jdx merged 2 commits intojdx:mainfrom
halms:docs/clarify-uv-venv-auto-deprecation
Mar 2, 2026
Merged

fix(python): clarify uv_venv_auto docs + prevent uv shim recursion in venv creation#8402
jdx merged 2 commits intojdx:mainfrom
halms:docs/clarify-uv-venv-auto-deprecation

Conversation

@halms
Copy link
Contributor

@halms halms commented Mar 2, 2026

Two related fixes for python.uv_venv_auto:

Docs: The warning block on the Python page was misleading — it said uv_venv_auto = true is "deprecated", but only the true value is being phased out, not the setting itself. Rewrites the warning to clarify this, and also explains the practical difference between the legacy true behavior (exports UV_PYTHON with just the version string, letting uv pick any matching Python) vs the recommended approach (using tools.python.path to strictly bind uv to the exact mise-managed Python binary).

Bug fix: When uv_venv_auto = "create|source" is set and a mise shim for uv exists on PATH (e.g. from another project), create_python_venv was finding the shim via which_non_pristine("uv"). Running the shim calls mise exec, which re-enters env resolution and calls create_python_venv again — causing infinite subprocess recursion and an endless stream of "mise creating venv with uv at: ..." messages.

Fix adds which_no_shims() that excludes $MISE_DATA_DIR/shims from the PATH search, and uses it in create_python_venv. Also handles Ok(false) from create_python_venv in uv_venv() correctly (previously fell through to load_venv on a non-existent path).

Copilot AI review requested due to automatic review settings March 2, 2026 00:01
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses two key areas related to mise's Python uv virtual environment integration. Firstly, it enhances the documentation for python.uv_venv_auto to provide clearer guidance on its usage and the implications of different configuration values, particularly concerning UV_PYTHON. Secondly, it resolves a critical bug that could lead to infinite recursion when mise attempts to create a uv virtual environment while a mise uv shim is present in the system's PATH, ensuring stable and predictable virtual environment creation.

Highlights

  • Documentation Clarification: The documentation for python.uv_venv_auto has been updated to clarify that only the true value is being deprecated, not the setting itself. It also explains the difference in UV_PYTHON behavior between the legacy true value and newer string values, providing an example for strictly binding uv to a mise-managed Python interpreter.
  • Bug Fix: UV Shim Recursion: A critical bug causing infinite subprocess recursion when uv_venv_auto is enabled and a mise uv shim exists on PATH has been resolved. This was due to create_python_venv finding and invoking the mise shim, which would re-enter environment resolution.
  • New Utility Function: which_no_shims: A new function which_no_shims was introduced in src/file.rs. This function searches the PATH for executables but explicitly excludes the mise shim directory, preventing internal mise processes from recursively calling mise shims.
  • Improved Error Handling for Venv Creation: The uv_venv function now correctly handles cases where create_python_venv returns Ok(false) (indicating uv was not available for venv creation), preventing attempts to load a non-existent virtual environment.
Changelog
  • docs/lang/python.md
    • Rewrote the warning block for python.uv_venv_auto = true to clarify that only the true value is deprecated, not the setting itself.
    • Explained the difference in UV_PYTHON behavior between the legacy true value and newer string values.
    • Added a configuration example to strictly bind uv to a mise-managed Python interpreter using tools.python.path.
  • e2e/core/test_python_uv_venv
    • Updated test configurations from .mise.toml to mise.toml.
    • Added a new test case to verify that mise's uv shim is not invoked during internal venv creation, preventing recursion.
  • src/config/env_directive/venv.rs
    • Replaced the which_non_pristine function call with the new which_no_shims function when looking up the uv binary for venv creation.
  • src/file.rs
    • Implemented a new public function which_no_shims that searches the PATH for an executable but explicitly excludes the mise shim directory to prevent recursive calls.
  • src/uv.rs
    • Modified the create_python_venv call within uv_venv to use a match statement, allowing for proper handling of Ok(false) (indicating uv was not available) to prevent attempting to load a non-existent venv.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces documentation clarifications and bug fixes for python.uv_venv_auto. The documentation is updated to clarify the deprecation of the true value. A bug causing infinite recursion when a mise shim for uv is in the PATH is fixed by adding a which_no_shims function to exclude the shim directory during executable lookups. A new e2e test verifies this fix. Additionally, the return value from the venv creation function is now handled correctly to prevent errors with non-existent venvs. The changes are well-implemented and I have no issues to report.

@halms halms force-pushed the docs/clarify-uv-venv-auto-deprecation branch from 4f0e548 to d71e0b2 Compare March 2, 2026 00:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves python.uv_venv_auto behavior and documentation by clarifying legacy vs recommended configuration, and preventing infinite recursion when a uv shim is present on PATH during venv auto-creation.

Changes:

  • Fix uv_venv() to correctly handle create_python_venv() returning Ok(false) (skip loading a non-existent venv).
  • Add which_no_shims() and use it for internal uv lookup to avoid invoking mise shims (and recursive re-entry).
  • Update E2E coverage for shim-exclusion behavior and clarify Python docs around the legacy true setting value.

Reviewed changes

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

Show a summary per file
File Description
src/uv.rs Handle Ok(false) from venv creation to avoid loading a missing .venv.
src/file.rs Introduce which_no_shims() to avoid shim-based recursion in internal tool lookups.
src/config/env_directive/venv.rs Use which_no_shims("uv") when creating venvs.
e2e/core/test_python_uv_venv Add regression test for shim recursion avoidance; switch config filename to mise.toml.
docs/lang/python.md Clarify that only the true value is legacy, and document a stricter UV_PYTHON configuration pattern.

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

@greptile-apps
Copy link

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR fixes a critical bug that caused infinite subprocess recursion when mise shims were on PATH during venv creation, and clarifies misleading documentation about the uv_venv_auto deprecation.

Key Changes:

  • Added which_no_shims() function to exclude $MISE_DATA_DIR/shims from PATH searches, preventing recursive shim invocation during venv creation
  • Fixed error handling in uv_venv() to correctly handle Ok(false) return value (previously would attempt to load non-existent venv)
  • Clarified documentation to explain that only uv_venv_auto = true is deprecated, not the setting itself
  • Added guidance on using UV_PYTHON with tools.python.path for strict Python interpreter binding
  • Added comprehensive test coverage for shim exclusion scenario
  • Updated test file naming from .mise.toml to mise.toml

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • All changes are well-implemented bug fixes with proper test coverage. The recursion fix addresses a real issue, error handling is improved, and documentation is clearer. No logical errors, security issues, or edge cases found.
  • No files require special attention

Important Files Changed

Filename Overview
src/file.rs Adds which_no_shims() function to prevent recursive shim invocation
src/uv.rs Fixes error handling to properly handle Ok(false) from create_python_venv()
src/config/env_directive/venv.rs Switches to which_no_shims() to avoid mise shim during venv creation

Last reviewed commit: d71e0b2

@jdx
Copy link
Owner

jdx commented Mar 2, 2026

bugbot run verbose=true

@cursor
Copy link

cursor bot commented Mar 2, 2026

Bugbot request id: serverGenReqId_ce9f1153-3037-44dc-82c3-62279e95492e

@jdx jdx enabled auto-merge (squash) March 2, 2026 00:14
auto-merge was automatically disabled March 2, 2026 00:19

Head branch was pushed to by a user without write access

The true value is considered legacy and will be deprecated in a future
release (2026.7), but the setting itself is not going away. Clarify
the difference between legacy `true` (exports UV_PYTHON with just the
version number) and the new recommended approach (using
`tools.python.path` to strictly pin uv to mise-managed Python).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@halms halms force-pushed the docs/clarify-uv-venv-auto-deprecation branch from b14c3c0 to 176ad55 Compare March 2, 2026 00:26
@halms
Copy link
Contributor Author

halms commented Mar 2, 2026

@jdx, I pushed changes to address the Copilot comments which I think were valid.
This disabled the auto-merge again.

…_auto

When `uv_venv_auto = "create|source"` is set and a mise shim for uv
exists on PATH (from another project), `which_non_pristine("uv")` would
find the shim. Running the shim invokes `mise exec`, which re-enters
the same venv creation path, causing infinite subprocess recursion
(printing "mise creating venv with uv at: ..." endlessly).

Fix by adding `which_no_shims()` that excludes the mise shim directory
from PATH searches, and using it in `create_python_venv`. Also handle
the `Ok(false)` return case in `uv_venv()` so that when venv creation
is skipped (e.g. uv unavailable), we correctly return None instead of
falling through to `load_venv` on a non-existent path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@halms halms force-pushed the docs/clarify-uv-venv-auto-deprecation branch from 176ad55 to c6442fd Compare March 2, 2026 00:43
@jdx jdx merged commit 4ba7aed into jdx:main Mar 2, 2026
34 checks passed
jdx pushed a commit that referenced this pull request Mar 2, 2026
### 🚀 Features

- **(hooks)** add task references to hooks and watch_files by @jdx in
[#8400](#8400)
- **(prepare)** add git-submodule built-in provider by @jdx in
[#8407](#8407)
- **(prepare)** add human-readable stale reasons to prepare output by
@jdx in [#8408](#8408)
- **(prepare)** add dependency ordering to prepare steps by @jdx in
[#8401](#8401)
- **(prepare)** add --explain flag for provider diagnostics by @jdx in
[#8409](#8409)
- **(prepare)** add per-provider timeout support by @jdx in
[#8405](#8405)
- **(prepare)** add blake3 content-hash freshness checking by @jdx in
[#8404](#8404)
- **(tasks)** monorepo vars and per-task vars by @halms in
[#8248](#8248)

### 🐛 Bug Fixes

- **(aqua)** restore bin_paths disk cache with fresh_file invalidation
by @jdx in [#8398](#8398)
- **(idiomatic)** use generic parser for idiomatic files by @risu729 in
[#8171](#8171)
- **(install)** apply precompiled options to all platforms in lockfile
by @jdx in [#8396](#8396)
- **(install)** normalize "v" prefix when matching lockfile versions by
@jdx in [#8413](#8413)
- **(prepare)** improve git submodule parser and fix check_staleness
error handling by @jdx in [#8412](#8412)
- **(python)** respect precompiled settings in lock file generation by
@jdx in [#8399](#8399)
- **(python)** clarify uv_venv_auto docs + prevent uv shim recursion in
venv creation by @halms in
[#8402](#8402)
- **(task)** remove deprecated `# mise` task header syntax by @jdx in
[#8403](#8403)
- **(vfox)** avoid eager metadata loading during config file detection
by @jdx in [#8397](#8397)
- clarify GitHub attestations to be artifact ones by @scop in
[#8394](#8394)
- ignore comments in idiomatic version files by @iloveitaly in
[#7682](#7682)

### 🚜 Refactor

- unify archive detection by @risu729 in
[#8137](#8137)

### 📚 Documentation

- remove duplicated docs for npm.package_manager by @risu729 in
[#8414](#8414)
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.

3 participants