Skip to content

Commit

Permalink
feat: rustup (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfrosty authored Jan 30, 2025
1 parent 1bd7b41 commit e1478c2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-months-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mucho": patch
---

ensure the installer checks for rustup AND rustc
3 changes: 3 additions & 0 deletions src/const/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const TOOL_CONFIG: { [key in ToolNames]: ToolCommandConfig } = {
pathSource: "$HOME/.cargo/env",
version: "rustc --version",
},
rustup: {
version: "rustup --version",
},
solana: {
dependencies: ["rust"],
pathSource: "$HOME/.local/share/solana/install/active_release/bin",
Expand Down
17 changes: 12 additions & 5 deletions src/lib/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,18 @@ export async function installRust({ version }: InstallCommandPropsBase = {}) {
}
}

let installedVersion = await installedToolVersion("rust");
if (installedVersion) {
spinner.info(`rust ${installedVersion} is already installed`);
// todo: detect if the $PATH is actually loaded
return true;
let [installedVersion, rustupVersion] = await Promise.all([
installedToolVersion("rust"),
installedToolVersion("rustup"),
]);

if (rustupVersion) {
installedVersion = await installedToolVersion("rust");
if (installedVersion) {
spinner.info(`rust ${installedVersion} is already installed`);
// todo: detect if the $PATH is actually loaded
return true;
}
}

spinner.text = "Installing the rust toolchain using rustup";
Expand Down
1 change: 1 addition & 0 deletions src/lib/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export async function checkInstalledTools({
let allInstalled = true;

let status: { [key in ToolNames]: string | boolean } = {
rustup: false,
rust: false,
solana: false,
avm: false,
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type PlatformOS = "unknown" | "linux" | "mac" | "windows";

export type ToolNames =
| "rust"
| "rustup"
| "solana"
| "avm"
| "anchor"
Expand Down

0 comments on commit e1478c2

Please sign in to comment.