jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
9.06k stars 245 forks source link

`.mise.toml` configuration: duplicate key `venv` in table `env` #2459

Open KabirDubey opened 4 weeks ago

KabirDubey commented 4 weeks ago

(first time user)

Describe the bug I'm unable to configure my .mise.toml file to enable automatic virtual environment activation in my python project directory. Any action in my test directory, which solely consists of my .mise.toml file, returns the following error:

Error loading settings file: TOML parse error at line 6, column 1
  |
6 | _.python.venv = "/root/.venv" # can be absolute
  | ^
duplicate key `venv` in table `env`

mise error parsing config file: ~/repos/test/.mise.toml
mise TOML parse error at line 6, column 1
  |
6 | _.python.venv = "/root/.venv" # can be absolute
  | ^
duplicate key `venv` in table `env`

mise Run with --verbose or MISE_VERBOSE=1 for more information
Error loading settings file: TOML parse error at line 6, column 1               
  |
6 | _.python.venv = "/root/.venv" # can be absolute
  | ^
duplicate key `venv` in table `env`

mise error parsing config file: ~/repos/test/.mise.toml
mise TOML parse error at line 6, column 1
  |
6 | _.python.venv = "/root/.venv" # can be absolute
  | ^
duplicate key `venv` in table `env`

mise Run with --verbose or MISE_VERBOSE=1 for more information

To Reproduce Get started:

  1. install mise using Homebrew.
  2. copy the activation script into ~/.zprofile (as opposed to ~/.zshrc)

Configure python version management:

  1. install the latest version of python
  2. make a test directory as a test project
  3. use nvim .mise.toml and paste this example from the documentation:
[tools]
python = "3.11" # [optional] will be used for the venv

[env]
_.python.venv = ".venv" # relative to this file's directory
_.python.venv = "/root/.venv" # can be absolute
_.python.venv = "{{env.HOME}}/.cache/venv/myproj" # can use templates
_.python.venv = { path = ".venv", create = true } # create the venv if it doesn't exist
  1. save and exit

Expected behavior I expect a python virtual environment to be automatically created and activated.

mise doctor output

version: 2024.8.6 macos-arm64 (574abfb 2024-08-12)
activated: yes
shims_on_path: no

build_info: 
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Mon, 12 Aug 2024 07:56:05 +0000
  Rust Version: rustc 1.80.0 (051478957 2024-07-21)
  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: 
  ~/.python-version
  ~/.config/mise/config.toml
  ~/.mise.toml

backends: 
  cargo
  core
  go
  npm
  pipx
  spm
  ubi

plugins: 
  bun     (core)
  deno    (core)
  erlang  (core)
  go      (core)
  java    (core)
  node    (core)
  python  (core)
  ruby    (core)

toolset: 
  python@3.12.5  

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 = false
  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
  http_timeout = 30
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  libgit2 = true
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "~/.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

No warnings found
No problems found
KabirDubey commented 3 weeks ago

Another .mise.toml file configuration with no environment variables does not work either. I locally install python version 3.10.14 with mise use python@3.10 and only write

[tools]
python = {version = '3.10', virtualenv = '.venv'}

but this gives

mise no venv found at: ~/repos/test/.venv                                       

To create a virtualenv manually, run:
python -m venv ~/repos/test/.venv

I expected .venv to be automatically created. I can create and activate .venv manually and it all works fine.

KabirDubey commented 3 weeks ago

Another .mise.toml file configuration with no environment variables does not work either. I locally install python version 3.10.14 with mise use python@3.10 and only write

[tools]
python = {version = '3.10', virtualenv = '.venv'}

Nevermind--adding a line

[tools]
python = {version='3.10', virtualenv='.venv'}

[env]
_.python.venv = { path = ".venv", create = true } # create the venv if it doesn't exist

automatically creates the .venv directory. This is a temporary solution; I assume that activating it is supposed to be manual. If you access the path with the key like this

[tools]
python = '3.10'

[env]
_.python.venv = ".venv"
_.python.venv = { path = ".venv", create = true } # create the venv if it doesn't exist

it's still seen as a duplicate.