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

mise hook_env and ignored_config_paths #3289

Closed
cpence opened this issue Nov 29, 2024 · 4 comments · Fixed by #3480
Closed

mise hook_env and ignored_config_paths #3289

cpence opened this issue Nov 29, 2024 · 4 comments · Fixed by #3480
Labels

Comments

@cpence
Copy link

cpence commented Nov 29, 2024

At the moment, mise hook-env does not respect settings.ignored_config_paths, so it is impossible to prevent mise from automatically running this command in a shell in which mise is activated.

This is problematic if mise runs slowly in a particular directory on your machine -- for example, because that directory is mounted over sshfs.

To Reproduce
Mount a directory over sshfs at, say, /mnt/work. Then:

 ~  mise doctor | grep ignored
  ignored_config_paths  ["/mnt/"] ~/.config/mise/config.toml
 ~  cd /mnt/work
 /m/work  time mise hook-env -s fish

________________________________________________________
Executed in  614.13 millis    fish           external
   usr time   25.13 millis    0.00 millis   25.13 millis
   sys time   22.47 millis    2.15 millis   20.32 millis

 /m/work  

Expected behavior
Because the /mnt path is ignored, mise hook-env should also quick-exit, rather than taking 600ms to show my prompt.

mise doctor output

version: 2024.11.36 linux-x64 (c4bc235 2024-11-29)
activated: yes
shims_on_path: no

build_info:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS
  Built: Fri, 29 Nov 2024 13:02:17 +0000
  Rust Version: rustc 1.82.0 (f6e511eec 2024-10-15) (Arch Linux rust 1:1.82.0-2)
  Profile: release

shell:
  /usr/bin/fish
  fish, version 3.7.1

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

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

backends:
  aqua
  asdf
  cargo
  core
  gem
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:

toolset:
  core:node@23.3.0
  core:python@3.13.0
  core:ruby@3.3.6
  npm:prettier@3.4.1
  pipx:black@24.10.0
  pipx:cpplint@2.0.0
  pipx:hatch@1.13.0
  pipx:isort@5.13.2
  pipx:keyring@25.5.0
  pipx:pypaperbot@1.4.0
  pipx:pyright@1.1.389

env_vars:
  MISE_SHELL=fish

settings:
  experimental          true      ~/.config/mise/config.toml
  ignored_config_paths  ["/mnt/"] ~/.config/mise/config.toml

No problems found
@cpence cpence added the bug label Nov 29, 2024
@jdx
Copy link
Owner

jdx commented Nov 30, 2024

it probably can't work if you don't set it as an env var. I don't think this can be fixed so we should update the docs.

@cpence
Copy link
Author

cpence commented Nov 30, 2024

I just tried setting the environment variable MISE_IGNORED_CONFIG_PATHS to /mnt and mise hook-env -s fish unfortunately still takes ~600ms in that folder.

@jdx
Copy link
Owner

jdx commented Nov 30, 2024

oh sorry, I misunderstood. The config does work for what it's designed to do: ignore any potential config files, however mise is still looking for files in those directories where it won't find anything because it's ignored.

I think this function needs to be updated to not be looking at ignored paths:

mise/src/config/mod.rs

Lines 764 to 785 in 6569478

pub fn load_config_paths(config_filenames: &[String], include_ignored: bool) -> Vec<PathBuf> {
let dirs = file::all_dirs().unwrap_or_default();
let mut config_files = dirs
.iter()
.flat_map(|dir| {
config_filenames
.iter()
.rev()
.flat_map(|f| glob(dir, f).unwrap_or_default().into_iter().rev())
})
.collect_vec();
config_files.extend(global_config_files());
config_files.extend(system_config_files());
config_files
.into_iter()
.unique_by(|p| file::desymlink_path(p))
.filter(|p| include_ignored || !config_file::is_ignored(p))
.collect()
}

I will probably get around to this in a few days but you're welcome to contribute, I don't think it's a difficult change.

jdx added a commit that referenced this issue Dec 11, 2024
jdx added a commit that referenced this issue Dec 11, 2024
jdx added a commit that referenced this issue Dec 11, 2024
jdx added a commit that referenced this issue Dec 11, 2024
@jdx jdx closed this as completed in #3480 Dec 11, 2024
@jdx jdx closed this as completed in 6e02eab Dec 11, 2024
@cpence
Copy link
Author

cpence commented Dec 11, 2024

Awesome, thanks so much! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants