From d1fb2de4844d020a5fa3a17609432f79ef544897 Mon Sep 17 00:00:00 2001 From: Jam Balaya Date: Wed, 24 Jun 2026 12:47:16 +0900 Subject: [PATCH] fix(which): respect prefer_offline so binary lookup avoids remote fetches (#10595) Co-authored-by: Claude Opus 4.8 --- e2e/cli/test_which_prefer_offline | 72 +++++++++++++++++++++++++++++++ settings.toml | 2 +- src/env.rs | 1 + 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 e2e/cli/test_which_prefer_offline diff --git a/e2e/cli/test_which_prefer_offline b/e2e/cli/test_which_prefer_offline new file mode 100644 index 0000000000..65dc0e50f3 --- /dev/null +++ b/e2e/cli/test_which_prefer_offline @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# Regression test for https://github.com/jdx/mise/discussions/10460 +# +# `mise which` is a binary lookup and must not require HTTP calls when an +# installed version already satisfies the request. It is now in the +# prefer-offline auto-enable list (like `where`, `ls`, `exec`), so even an +# explicit `minimum_release_age` cutoff -- which normally forces date-aware +# remote resolution on regular commands -- must keep resolving from installed +# versions instead of fetching a remote version list. +# +# Scope: this covers config-file tools. An explicit `--tool=spy@1` argument is +# a `ToolSource::Argument` request, which intentionally opts out of +# prefer-offline so explicit version requests resolve accurately (see #10571), +# consistent with `mise exec`/`mise x`; that path is not exercised here. + +# Copy the dummy plugin into one whose remote version-listing scripts leave a +# marker file behind when they run, making any remote fetch directly +# observable. (cat > preserves the executable bit from the copied scripts.) +marker="$HOME/remote-versions-fetched" +cp -RL "$MISE_DATA_DIR/plugins/dummy" "$MISE_DATA_DIR/plugins/spy" +cat >"$MISE_DATA_DIR/plugins/spy/bin/list-all" <"$MISE_DATA_DIR/plugins/spy/bin/latest-stable" <mise.toml < bool { "hook-env", "ls", "where", + "which", "x", ] .contains(&a.as_str())