Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions e2e/cli/test_bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ assert_succeed "mise bootstrap packages install --dry-run --yes"
# idempotent: re-running is fine
assert_succeed "mise bootstrap --yes"

# settings from configs installed by dotfiles are visible to the bootstrap task
rm -f bootstrap_ran deps_ran
mkdir -p dotfiles/mise
cat <<'EOF' >dotfiles/mise/config.toml
[settings]
experimental = true
EOF
cat <<'EOF' >mise.toml
[deps.bootstrap-test]
auto = true
outputs = ["deps_ran"]
run = "touch deps_ran"

[tasks.bootstrap]
run = "touch bootstrap_ran"

[dotfiles]
"~/.config/mise/config.toml" = "dotfiles/mise/config.toml"
EOF
assert_succeed "mise bootstrap --yes"
assert "test -f deps_ran"
assert "test -f bootstrap_ran"
Comment thread
risu729 marked this conversation as resolved.
Resolved

# dry-run doesn't install or run anything
rm -f bootstrap_ran
cat <<EOF >mise.toml
Expand Down
13 changes: 13 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl Config {
}
pub async fn reset() -> Result<Arc<Self>> {
backend::reset().await?;
Settings::reload();
timeout::run_with_timeout_async(
async || {
_CONFIG.write().unwrap().take();
Expand Down Expand Up @@ -3242,6 +3243,18 @@ mod tests {
assert_debug_snapshot!(config);
}

#[tokio::test]
async fn test_reset_reloads_settings() {
Settings::reset(None);
let before = Settings::get();

Config::reset().await.unwrap();
let after = Settings::get();

assert!(!Arc::ptr_eq(&before, &after));
Settings::reset(None);
}

#[test]
fn test_config_set_contains_matches_symlinked_prefix() {
// Regression for https://github.com/jdx/mise/discussions/10483:
Expand Down
18 changes: 18 additions & 0 deletions src/config/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,12 @@ impl Settings {
crate::config::config_file::config_root::reset();
}

/// Invalidate settings loaded from config files without discarding CLI overrides.
pub fn reload() {
*BASE_SETTINGS.write().unwrap() = None;
crate::config::config_file::config_root::reset();
}

/// Merge an override into the CLI-level settings partial.
///
/// `reset` replaces CLI_SETTINGS wholesale, which would clobber overrides
Expand Down Expand Up @@ -1610,6 +1616,18 @@ mod tests {
Settings::reset(None);
}

#[test]
fn test_reload_preserves_cli_settings() {
let mut partial = SettingsPartial::empty();
partial.offline = Some(true);
Settings::reset(Some(partial));
assert!(Settings::get().offline());

Settings::reload();
assert!(Settings::get().offline());
Settings::reset(None);
}

#[test]
fn test_offline_implies_prefer_offline() {
let mut partial = SettingsPartial::empty();
Expand Down