Skip to content

Commit

Permalink
hide system versions from env/bin_paths
Browse files Browse the repository at this point in the history
Fixes #1549
  • Loading branch information
jdx committed Jan 29, 2024
1 parent 986aa0c commit 35fc35f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'''
7 changes: 7 additions & 0 deletions e2e/test_bin_paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# shellcheck source-path=SCRIPTDIR
source "$(dirname "$0")/assert.sh"

mise use go@system
assert_not_contains "mise env -s bash" "go/system"
4 changes: 4 additions & 0 deletions e2e/test_go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/core/deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ impl Forge for DenoPlugin {
}

fn list_bin_paths(&self, tv: &ToolVersion) -> Result<Vec<PathBuf>> {
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"),
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/core/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -166,6 +166,9 @@ impl Forge for GoPlugin {
}

fn list_bin_paths(&self, tv: &ToolVersion) -> Result<Vec<PathBuf>> {
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) {
Expand Down
2 changes: 2 additions & 0 deletions src/toolset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -323,6 +324,7 @@ impl Toolset {
pub fn list_paths(&self) -> Vec<PathBuf> {
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:#}");
Expand Down

0 comments on commit 35fc35f

Please sign in to comment.