Skip to content

Commit

Permalink
fix: Ensure dependencies are available for alternative backends (jdx#…
Browse files Browse the repository at this point in the history
…2532)

* ensure dependencies are loaded for experimental backends

* fix cargo-binstall

* fix test

* simplicy e2e test
  • Loading branch information
xavdid authored and triarius committed Sep 18, 2024
1 parent b3478cc commit da4b97c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions e2e/backend/test_npm
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export NPM_CONFIG_FUND=false
mise use node
assert "mise x npm:prettier@3.1.0 -- prettier -v" "3.1.0"
assert "FORCE_COLOR=0 mise x npm:@antfu/ni@0.21.12 -- ni -v 2>/dev/null | head -n1" "@antfu/ni v0.21.12"
assert_succeed "mise install npm:tldr@3.4.0"
1 change: 1 addition & 0 deletions src/backend/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl Backend for CargoBackend {
.with_pr(ctx.pr.as_ref())
.envs(ctx.ts.env_with_path(&config)?)
.prepend_path(ctx.ts.list_paths())?
.prepend_path(self.depedency_toolset()?.list_paths())?
.execute()?;

Ok(())
Expand Down
8 changes: 6 additions & 2 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ pub trait Backend: Debug + Send + Sync {
tv.cache_path().join("incomplete")
}

fn dependency_env(&self) -> eyre::Result<BTreeMap<String, String>> {
fn depedency_toolset(&self) -> eyre::Result<Toolset> {
let config = Config::get();
let dependencies = self
.get_all_dependencies(&ToolRequest::System(self.name().into()))?
Expand All @@ -487,7 +487,11 @@ pub trait Backend: Debug + Send + Sync {
.filter_by_tool(&dependencies)
.into();
ts.resolve()?;
ts.full_env()
Ok(ts)
}

fn dependency_env(&self) -> eyre::Result<BTreeMap<String, String>> {
self.depedency_toolset()?.full_env()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/backend/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl Backend for NPMBackend {
.with_pr(ctx.pr.as_ref())
.envs(ctx.ts.env_with_path(&config)?)
.prepend_path(ctx.ts.list_paths())?
.prepend_path(self.depedency_toolset()?.list_paths())?
.execute()?;

Ok(())
Expand Down
2 changes: 2 additions & 0 deletions src/backend/pipx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl Backend for PIPXBackend {
.prepend_path(ctx.ts.list_paths())?
// Prepend install path so pipx doesn't issue a warning about missing path
.prepend_path(vec![ctx.tv.install_path().join("bin")])?
.prepend_path(self.depedency_toolset()?.list_paths())?
.execute()?;
} else {
CmdLineRunner::new("pipx")
Expand All @@ -108,6 +109,7 @@ impl Backend for PIPXBackend {
.prepend_path(ctx.ts.list_paths())?
// Prepend install path so pipx doesn't issue a warning about missing path
.prepend_path(vec![ctx.tv.install_path().join("bin")])?
.prepend_path(self.depedency_toolset()?.list_paths())?
.execute()?;
}
Ok(())
Expand Down
3 changes: 2 additions & 1 deletion src/backend/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ impl Backend for UbiBackend {
.arg(self.name())
.with_pr(ctx.pr.as_ref())
.envs(ctx.ts.env_with_path(&config)?)
.prepend_path(ctx.ts.list_paths())?;
.prepend_path(ctx.ts.list_paths())?
.prepend_path(self.depedency_toolset()?.list_paths())?;

if let Some(token) = &*GITHUB_TOKEN {
cmd = cmd.env("GITHUB_TOKEN", token);
Expand Down

0 comments on commit da4b97c

Please sign in to comment.