Skip to content

Commit

Permalink
Mise plugin checks multiple install locations for mise binary
Browse files Browse the repository at this point in the history
The installation path of Mise differs through the installation method
chosen. Using Homebrew results in a path under `/opt/homebrew` where as
the installation method from the Mise website is typically under
`$HOME/.local`.
  • Loading branch information
adam12 committed Nov 30, 2024
1 parent 0a82b93 commit de53091
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions vscode/src/ruby/mise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,40 @@ export class Mise extends VersionManager {
const misePath = config.get<string | undefined>(
"rubyVersionManager.miseExecutablePath",
);
const miseUri = misePath
? vscode.Uri.file(misePath)
: vscode.Uri.joinPath(
vscode.Uri.file(os.homedir()),
".local",
"bin",
"mise",

if (misePath) {
const configuredPath = vscode.Uri.file(misePath);

try {
await vscode.workspace.fs.stat(configuredPath);
return configuredPath;
} catch (error: any) {
throw new Error(
`Mise executable configured as ${configuredPath}, but that file doesn't exist`,
);
}
}

// Possible mise installation paths
//
// 1. Installation from curl | sh (per mise.jdx.dev Getting Started)
// 2. Homebrew M series
const possiblePaths = [
vscode.Uri.joinPath(vscode.Uri.file(os.homedir()), ".local", "bin", "mise"),

Check failure on line 52 in vscode/src/ruby/mise.ts

View workflow job for this annotation

GitHub Actions / lint_node

Replace `vscode.Uri.file(os.homedir()),·".local",·"bin",·"mise"` with `⏎········vscode.Uri.file(os.homedir()),⏎········".local",⏎········"bin",⏎········"mise",⏎······`
vscode.Uri.joinPath(vscode.Uri.file("/"), "opt", "homebrew", "bin", "mise")

Check failure on line 53 in vscode/src/ruby/mise.ts

View workflow job for this annotation

GitHub Actions / lint_node

Replace `vscode.Uri.file("/"),·"opt",·"homebrew",·"bin",·"mise")` with `⏎········vscode.Uri.file("/"),⏎········"opt",⏎········"homebrew",⏎········"bin",⏎········"mise",⏎······),`
];

try {
await vscode.workspace.fs.stat(miseUri);
return miseUri;
} catch (error: any) {
// Couldn't find it
for (const possiblePath of possiblePaths) {
try {
await vscode.workspace.fs.stat(possiblePath);
return possiblePath;
} catch (error: any) {
// Continue looking
}
}

throw new Error(
`The Ruby LSP version manager is configured to be Mise, but ${miseUri.fsPath} does not exist`,
`The Ruby LSP version manager is configured to be Mise, but could not find Mise installation. Searched in ${possiblePaths.join(", ")}`,

Check failure on line 66 in vscode/src/ruby/mise.ts

View workflow job for this annotation

GitHub Actions / lint_node

This line has a length of 141. Maximum allowed is 120
);
}
}

0 comments on commit de53091

Please sign in to comment.