jdx / mise

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

`mise trust` works incorrectly with symlinked configuration file #2175

Closed toupeira closed 4 months ago

toupeira commented 4 months ago

Describe the bug

My configuration file is symlinked from ~/.config/mise/config.toml to /etc/dotfiles/config/mise/config.toml, this worked fine in Mise prior to version 2024.5.11 but now results in an error Config file is not trusted.

The symlink in ~/.local/state/mise/trusted-configs looks correct:

$ ls -l ~/.local/state/mise/trusted-configs/
total 4
-rw-rw-r-- 1 toupeira toupeira 64 Mai 23 11:35 mise-config.hash
lrwxrwxrwx 1 toupeira toupeira 37 Mai 23 11:35 mise-config.toml-7519310cd5e2132a -> /etc/dotfiles/config/mise/config.toml

But mise trust seems to use the realpath when creating the symlink, and the original path when checking:

$ mise -v trust
[DEBUG] ARGS: mise -v trust
[INFO] mise trusted /etc/dotfiles/config/mise/config.toml
mise Config file is not trusted.
Trust it with `mise trust`.
mise Run with --verbose or MISE_VERBOSE=1 for more information

Running other commands shows this prompt, asking if the original path should be trusted:

$ mise exec -- fzf
 mise ~/.config/mise/config.toml is not trusted. Trust it?

   Yes     No  

←/→ toggle • y/n/enter submit

This creates a second symlink and fixes the Config file is not trusted. error:

$ ls -l ~/.local/state/mise/trusted-configs/
total 4
-rw-rw-r-- 1 toupeira toupeira 64 Mai 23 11:37 mise-config.hash
lrwxrwxrwx 1 toupeira toupeira 39 Mai 23 11:37 mise-config.toml-2ce2d28d2e83642d -> /home/toupeira/.config/mise/config.toml
lrwxrwxrwx 1 toupeira toupeira 37 Mai 23 11:35 mise-config.toml-7519310cd5e2132a -> /etc/dotfiles/config/mise/config.toml

To Reproduce

Use a symlink for ~/.config/mise/config.toml

Expected behavior

This should work without errors.

mise doctor output

version: 2024.5.21 linux-x64 (ef24c46 2024-05-23)
activated: yes
shims_on_path: no

build_info: 
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Thu, 23 May 2024 01:53:55 +0000
  Rust Version: rustc 1.78.0 (9b00956e5 2024-04-29)
  Profile: release

shell: 
  /bin/bash
  GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
  Copyright (C) 2022 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

  This is free software; you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

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

config_files: 
  ~/.config/mise/config.toml

backends: 
  cargo
  core
  go
  npm
  pipx
  ubi

plugins: 
  bun      (core)
  deno     (core)
  erlang   (core)
  fzf      https://github.com/kompiro/asdf-fzf.git#d19eb67
  go       (core)
  helm     https://github.com/Antiarchitect/asdf-helm.git#f4b7f38
  java     (core)
  jq       https://github.com/mise-plugins/asdf-jq.git#6d86d19
  kubectl  https://github.com/asdf-community/asdf-kubectl.git#cbe6df4
  neovim   https://github.com/richin13/asdf-neovim.git#d6118ad
  node     (core)
  python   (core)
  rclone   https://github.com/johnlayton/asdf-rclone.git#6d0fb47
  ruby     (core)
  usage    https://github.com/jdx/mise-usage.git#fe3888a
  yarn     https://github.com/twuni/asdf-yarn.git#376c540

toolset: 
  ruby@3.3.1     
  node@22.2.0    
  fzf@0.52.1     
  usage@0.2.0    
  neovim@0.10.0  

env_vars: 
  MISE_SHELL=bash

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

Additional context Add any other context about the problem here.

toupeira commented 4 months ago

Thanks for the quick fix @roele! :bow: