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

Nested Python venvs lead to wrong path order #1771

Closed
halms opened this issue Mar 13, 2024 · 2 comments
Closed

Nested Python venvs lead to wrong path order #1771

halms opened this issue Mar 13, 2024 · 2 comments
Labels

Comments

@halms
Copy link

halms commented Mar 13, 2024

Describe the bug
If I have a .mise.toml, say in folder ~/dev/project1 file that defines a python venv with

[env]
_.python.venv = '.venv'

and then have another .mise.toml in some subfolder of ~/dev/project1, say ~/dev/project1/src/notebooks that also defines a venv, then there are a few weird behaviors:

  1. I cannot easily create a venv with the specified python version directly, because the venv of the parent folder is still active
    So python -m venv .venv would actually create the venv using the Python binary from the parent venv
  2. If I manage to correctly do (1), e.g. using the full path to the correct python version, then, when the new venv is activated, the PATH is not correct.
    I have the bin of the venv of the parent folder before the bin of the current venv, so actually the wrong python binaries come first.

I know this is a bit of a weird edge case, but I have an actual use case for it.

To Reproduce
Described above: create two .mise.tomls specifying a Python venv in two nested folders.
Enter the lower folder.
Investigate $PATH

Expected behavior
About 1.: Actually, I would expect the parent venv to not be active when another venv is specified in .mise.toml, but doesn't exist.
So that if I am in the nested folder, python would refer to the python version specified in tools, and not the parent venv
(This might need a bit more thought / discussion)

About 2.: Here I'm more confident. If the nested venv gets activated, the parent venv should not be on the path anymore at all.
It definitely should not come before the nested venv.

mise doctor output

version: 2024.3.1 macos-arm64 (2024-03-04)
activated: yes
shims_on_path: yes

build_info:
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS
  Built: Mon, 4 Mar 2024 22:28:40 +0000
  Rust Version: rustc 1.76.0 (07dca489a 2024-02-04) (Homebrew)
  Profile: release

shell:
  /bin/zsh
  zsh 5.9 (x86_64-apple-darwin23.0)

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

config_files:
  ~/.config/mise/config.toml
  ~/dev/project1/.mise.local.toml # redacted, but maintaining correct structure
  ~/dev/project1/src/notebooks/.mise.local.toml # redacted, but maintaining correct structure

plugins:
  bun     (core)
  deno    (core)
  erlang  (core)
  go      (core)
  java    (core)
  node    (core)
  python  (core)
  ruby    (core)
  usage   https://github.com/jdx/mise-usage.git#fe3888a

toolset:
  [email protected]
  [email protected]
  [email protected]
  [email protected]
  [email protected]

env_vars:
  MISE_SHELL=zsh

settings:
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = true
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_compile = false
  python_default_packages_file = "/Users/daniel/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = false
@halms halms added the bug label Mar 13, 2024
@noirbizarre
Copy link
Contributor

It seems to be a duplicate of #1724

@jdx
Copy link
Owner

jdx commented Mar 16, 2024

#1751

@jdx jdx closed this as completed Mar 16, 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

3 participants