feat(MISE_CEILING_PATHS): Add a ceiling to how mise searchs for config & tasks #6041
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem: mise recurses upwards from cwd looking for and loading config and tasks files. When mise accesses a directory that is slow to load it has a noticable impact on performance of mise activate In my work environment this is due to use of autofs/automount on /home - meaning when I use mise under /home/username there is a slowdown as mise looks for config file such as /home/.mise.toml
Solution: Implement something similar to git's GIT_CEILING_DIRECTORIES, a list of directories at which mise will stop recursing up.
Users control this by setting
MISE_CEILING_PATHS
environment variable. In my case, I'd set this to include /home, meaning /home/username is the last directory searched.This can be a set to a list of directories which are separated by the platform's conventions for PATH meaning
:
for Linux/macS and;
for Windows. But basically I'm usingstd::env::split_paths
, so that's the definition.All the interesting work here seem to be in
src/config/mod.rs
, there are three places that callfile::all_dirs()
to get the list of ancestor folders of cwdload_config_paths
load_local_tasks
config_file_from_dir
Updated the signature of all_dirs to
all_dirs<P: AsRef<Path>>(start_dir: P, ceiling_dirs: &HashSet<PathBuf>) -> Result<Vec<PathBuf>>
start_dir
helps with testability (unit tests added)ancestors()
Provided a wrapper
all_dirs
insrc/config/mod.rs
that passes in the current dir, and the value ofMISE_CEILING_PATHS
as aHashSet
Added e2e tests to check that search for config files and file tasks both stop at the ceiling.
Added (brief) documentation to
configuration.md
e2e-win
test, good catch differences any assumptions about file systems and the behaviour ofsplit_path
--
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY.