Skip to content

Commit

Permalink
fix: Fix globals directory not being located. (#1045)
Browse files Browse the repository at this point in the history
* Add locate bins.

* Update rust.

* Bump version.
  • Loading branch information
milesj authored Sep 7, 2023
1 parent 109dd1c commit 11cdb42
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .yarn/versions/4539b14a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
releases:
"@moonrepo/cli": patch
"@moonrepo/core-linux-arm64-gnu": patch
"@moonrepo/core-linux-arm64-musl": patch
"@moonrepo/core-linux-x64-gnu": patch
"@moonrepo/core-linux-x64-musl": patch
"@moonrepo/core-macos-arm64": patch
"@moonrepo/core-macos-x64": patch
"@moonrepo/core-windows-x64-msvc": patch
2 changes: 2 additions & 0 deletions crates/node/tool/src/node_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ impl Tool for NodeTool {
}
}

self.tool.locate_globals_dir().await?;

if let Some(npm) = &mut self.npm {
installed += npm.setup(last_versions).await?;
}
Expand Down
4 changes: 4 additions & 0 deletions crates/node/tool/src/npm_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ impl Tool for NpmTool {
let version_type = VersionType::parse(&version)?;

if self.tool.is_setup(&version_type).await? {
self.tool.locate_globals_dir().await?;

debug!("npm has already been setup");

return Ok(count);
Expand Down Expand Up @@ -98,6 +100,8 @@ impl Tool for NpmTool {
count += 1;
}

self.tool.locate_globals_dir().await?;

Ok(count)
}

Expand Down
4 changes: 4 additions & 0 deletions crates/node/tool/src/pnpm_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ impl Tool for PnpmTool {
let version_type = VersionType::parse(&version)?;

if self.tool.is_setup(&version_type).await? {
self.tool.locate_globals_dir().await?;

debug!("pnpm has already been setup");

return Ok(count);
Expand Down Expand Up @@ -100,6 +102,8 @@ impl Tool for PnpmTool {
count += 1;
}

self.tool.locate_globals_dir().await?;

Ok(count)
}

Expand Down
4 changes: 4 additions & 0 deletions crates/node/tool/src/yarn_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ impl Tool for YarnTool {
let version_type = VersionType::parse(&version)?;

if self.tool.is_setup(&version_type).await? {
self.tool.locate_globals_dir().await?;

debug!("yarn has already been setup");

return Ok(count);
Expand Down Expand Up @@ -148,6 +150,8 @@ impl Tool for YarnTool {
count += 1;
}

self.tool.locate_globals_dir().await?;

Ok(count)
}

Expand Down
22 changes: 11 additions & 11 deletions crates/rust/platform/src/rust_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,11 @@ impl Platform for RustPlatform {
if !self.config.bins.is_empty() {
print_checkpoint("cargo binstall", Checkpoint::Setup);

let globals_dir = tool.tool.get_globals_bin_dir();

// Install cargo-binstall if it does not exist
if !tool
.tool
.get_globals_bin_dir()
.unwrap()
.join("cargo-binstall")
.exists()
if globals_dir.is_none()
|| globals_dir.is_some_and(|p| !p.join("cargo-binstall").exists())
{
debug!(
target: LOG_TARGET,
Expand Down Expand Up @@ -482,11 +480,13 @@ impl Platform for RustPlatform {
}
// Binary may be installed to ~/.cargo/bin
_ => {
let globals_dir = if let Ok(tool) = self.toolchain.get() {
tool.tool.get_globals_bin_dir().unwrap().to_path_buf()
} else {
get_cargo_home().join("bin")
};
let mut globals_dir = get_cargo_home().join("bin");

if let Ok(tool) = self.toolchain.get() {
if let Some(new_globals_dir) = tool.tool.get_globals_bin_dir() {
globals_dir = new_globals_dir.to_path_buf();
}
}

let global_bin_path = globals_dir.join(&task.command);

Expand Down
2 changes: 2 additions & 0 deletions crates/rust/tool/src/rust_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ impl Tool for RustTool {
}
}

self.tool.locate_globals_dir().await?;

Ok(installed)
}

Expand Down
7 changes: 7 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

#### 🐞 Fixes

- Fixed an issue where tool globals directory was not being correctly located.
- Fixed a panic when using the `rust` toolchain and attempting to install `bins`.

## 1.13.2

#### 🐞 Fixes
Expand Down

0 comments on commit 11cdb42

Please sign in to comment.