From c018963e2e77b17a58c7aec0e7b64b18fa4a22e8 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdx@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:37:55 -0600 Subject: [PATCH] hide system versions from env/bin_paths Fixes #1549 --- .mise.toml | 14 ++++++++++++++ e2e/test_bin_paths | 7 +++++++ e2e/test_go | 4 ++++ justfile | 4 +++- src/plugins/core/deno.rs | 3 +++ src/plugins/core/go.rs | 5 ++++- src/toolset/mod.rs | 2 ++ 7 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 e2e/test_bin_paths diff --git a/.mise.toml b/.mise.toml index 0dc687217..1c47d3a3e 100644 --- a/.mise.toml +++ b/.mise.toml @@ -92,3 +92,17 @@ run = "just lint-fix" [tasks.signal-test] run = "node ./test/fixtures/signal-test.js" + +[tasks."test:e2e"] +run = "just test-e2e" +# TODO: make this work when we have task args +#run = ''' +#set -euo pipefail +#TEST="$1" +#if [ "TEST" = all ]; then +# echo ./e2e/run_all_tests +#else +# FILES="$(fd TEST e2e/)" +# echo ./e2e/run_test "$FILES" +#fi +#''' diff --git a/e2e/test_bin_paths b/e2e/test_bin_paths new file mode 100755 index 000000000..334998ccd --- /dev/null +++ b/e2e/test_bin_paths @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -euo pipefail +# shellcheck source-path=SCRIPTDIR +source "$(dirname "$0")/assert.sh" + +mise use go@system +mise bin-paths | grep -v go/system diff --git a/e2e/test_go b/e2e/test_go index 8142df26d..f1c3d6ee6 100755 --- a/e2e/test_go +++ b/e2e/test_go @@ -15,3 +15,7 @@ assert_contains "mise x -- go version" "go version go1.20" rm "$MISE_GO_DEFAULT_PACKAGES_FILE" chmod -R u+w "$MISE_DATA_DIR/installs/go" + +assert_contains "mise env -s bash" "GOPATH" +mise use golang@system +assert_not_contains "mise env -s bash" "GOPATH" diff --git a/justfile b/justfile index 41f666e8d..775f89fd4 100644 --- a/justfile +++ b/justfile @@ -37,7 +37,9 @@ test-e2e TEST=("all"): build ./e2e/run_all_tests else FILES="$(fd {{ TEST }} e2e/)" - ./e2e/run_test "$FILES" + for FILE in $FILES; do + ./e2e/run_test "$FILE" + done fi # run unit tests w/ coverage diff --git a/src/plugins/core/deno.rs b/src/plugins/core/deno.rs index 79648b533..bed7bcc29 100644 --- a/src/plugins/core/deno.rs +++ b/src/plugins/core/deno.rs @@ -124,6 +124,9 @@ impl Forge for DenoPlugin { } fn list_bin_paths(&self, tv: &ToolVersion) -> Result> { + if let ToolVersionRequest::System(_) = tv.request { + return Ok(vec![]); + } let bin_paths = vec![ tv.install_short_path().join("bin"), tv.install_short_path().join(".deno/bin"), diff --git a/src/plugins/core/go.rs b/src/plugins/core/go.rs index 63291bb26..9352eb523 100644 --- a/src/plugins/core/go.rs +++ b/src/plugins/core/go.rs @@ -13,7 +13,7 @@ use crate::forge::Forge; use crate::http::HTTP; use crate::install_context::InstallContext; use crate::plugins::core::CorePlugin; -use crate::toolset::{ToolVersion, Toolset}; +use crate::toolset::{ToolVersion, ToolVersionRequest, Toolset}; use crate::ui::progress_report::SingleReport; use crate::{cmd, env, file, hash}; @@ -166,6 +166,9 @@ impl Forge for GoPlugin { } fn list_bin_paths(&self, tv: &ToolVersion) -> Result> { + if let ToolVersionRequest::System(_) = tv.request { + return Ok(vec![]); + } // goroot/bin must always be included, irrespective of MISE_GO_SET_GOROOT let mut paths = vec![self.goroot(tv).join("bin")]; if *env::MISE_GO_SET_GOPATH != Some(false) { diff --git a/src/toolset/mod.rs b/src/toolset/mod.rs index 1ba636118..9d940feef 100644 --- a/src/toolset/mod.rs +++ b/src/toolset/mod.rs @@ -293,6 +293,7 @@ impl Toolset { let entries = self .list_current_installed_versions() .into_par_iter() + .filter(|(_, tv)| !matches!(tv.request, ToolVersionRequest::System(_))) .flat_map(|(p, tv)| match p.exec_env(config, self, &tv) { Ok(env) => env.into_iter().collect(), Err(e) => { @@ -323,6 +324,7 @@ impl Toolset { pub fn list_paths(&self) -> Vec { self.list_current_installed_versions() .into_par_iter() + .filter(|(_, tv)| !matches!(tv.request, ToolVersionRequest::System(_))) .flat_map(|(p, tv)| { p.list_bin_paths(&tv).unwrap_or_else(|e| { warn!("Error listing bin paths for {tv}: {e:#}");