Skip to content

Conversation

richardthe3rd
Copy link

@richardthe3rd richardthe3rd commented Aug 15, 2025

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 using std::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 call file::all_dirs() to get the list of ancestor folders of cwd

  • load_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>>

  • Passing in start_dir helps with testability (unit tests added)
  • The second argument is the set of "ceiling" directories that are used to stop the iteration
  • Also rewrote to use ancestors()

Provided a wrapper all_dirs in src/config/mod.rs that passes in the current dir, and the value of MISE_CEILING_PATHS as a HashSet

Added e2e tests to check that search for config files and file tasks both stop at the ceiling.

Added (brief) documentation to configuration.md

  • Add a e2e-win test, good catch differences any assumptions about file systems and the behaviour of split_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.

Richard Alcock and others added 10 commits August 15, 2025 17:31
… support

Update  function `all_dirs` that returns a list of directories starting from
 a given path and traversing upward through all ancestors until either:
1. A ceiling directory is reached (if specified in the ceiling_dirs HashSet)
2. The root directory is reached

This allows for controlled directory traversal with configurable boundaries,
which is useful for operations that need to search upward in the file system
but should stop at certain points.

The function includes comprehensive test coverage for various scenarios including:
- No ceiling directories
- Single ceiling directory
- Multiple ceiling directories
- Ceiling at the start directory
- Relative path handling
… mise search for config and task files

MISE_CEILING_PATHS is interpreted as a HashSet and passed to file::all_dirs

Added e2e test for config files
Use std::env::split_paths to split MISE_CEILING_PATHS to get required behaviour on Windows. Update documentation for `MISE_CEILING_PATHS` to explain this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant