@@ -9,10 +9,10 @@ import { VersionManager, ActivationResult, NonReportableError } from "./versionM
99// Learn more: https://github.com/jdx/mise
1010export class Mise extends VersionManager {
1111 async activate ( ) : Promise < ActivationResult > {
12- const miseUri = await this . findMiseUri ( ) ;
12+ const miseExec = await this . findMise ( ) ;
1313
1414 // The exec command in Mise is called `x`
15- const parsedResult = await this . runEnvActivationScript ( `${ miseUri . fsPath } x -- ruby` ) ;
15+ const parsedResult = await this . runEnvActivationScript ( `${ miseExec } x -- ruby` ) ;
1616
1717 return {
1818 env : { ...process . env , ...parsedResult . env } ,
@@ -22,46 +22,37 @@ export class Mise extends VersionManager {
2222 } ;
2323 }
2424
25- async findMiseUri ( ) : Promise < vscode . Uri > {
25+ async findMise ( ) : Promise < string > {
2626 const config = vscode . workspace . getConfiguration ( "rubyLsp" ) ;
27- const misePath = config . get < string | undefined > ( "rubyVersionManager.miseExecutablePath" ) ;
27+ const configuredMisePath = config . get < string | undefined > ( "rubyVersionManager.miseExecutablePath" ) ;
2828
29- if ( misePath ) {
30- const configuredPath = vscode . Uri . file ( misePath ) ;
31-
32- try {
33- await vscode . workspace . fs . stat ( configuredPath ) ;
34- return configuredPath ;
35- } catch ( _error : any ) {
36- throw new NonReportableError (
37- `Mise executable configured as ${ configuredPath . fsPath } , but that file doesn't exist` ,
38- ) ;
39- }
29+ if ( configuredMisePath ) {
30+ return this . ensureMiseExistsAt ( configuredMisePath ) ;
4031 }
4132
42- // Possible mise installation paths
33+ // Possible mise installation directories. If none match, fall back to the PATH.
4334 //
4435 // 1. Installation from curl | sh (per mise.jdx.dev Getting Started)
4536 // 2. Homebrew M series
46- // 3. Installation from `apt install mise`
37+ // 3. Homebrew Intel / Linuxbrew
38+ // 4. Linuxbrew (legacy)
39+ // 5. Installation from `apt install mise`
4740 const possiblePaths = [
48- vscode . Uri . joinPath ( vscode . Uri . file ( os . homedir ( ) ) , ".local" , "bin" , "mise" ) ,
49- vscode . Uri . joinPath ( vscode . Uri . file ( "/" ) , "opt" , "homebrew" , "bin" , "mise" ) ,
50- vscode . Uri . joinPath ( vscode . Uri . file ( "/" ) , "usr" , "bin" , "mise" ) ,
41+ vscode . Uri . joinPath ( vscode . Uri . file ( os . homedir ( ) ) , ".local" , "bin" ) ,
42+ vscode . Uri . joinPath ( vscode . Uri . file ( "/" ) , "opt" , "homebrew" , "bin" ) ,
43+ vscode . Uri . joinPath ( vscode . Uri . file ( "/" ) , "usr" , "local" , "bin" ) ,
44+ vscode . Uri . joinPath ( vscode . Uri . file ( "/" ) , "home" , "linuxbrew" , ".linuxbrew" , "bin" ) ,
45+ vscode . Uri . joinPath ( vscode . Uri . file ( "/" ) , "usr" , "bin" ) ,
5146 ] ;
47+ return this . findExec ( possiblePaths , "mise" ) ;
48+ }
5249
53- for ( const possiblePath of possiblePaths ) {
54- try {
55- await vscode . workspace . fs . stat ( possiblePath ) ;
56- return possiblePath ;
57- } catch ( _error : any ) {
58- // Continue looking
59- }
50+ private async ensureMiseExistsAt ( path : string ) : Promise < string > {
51+ try {
52+ await vscode . workspace . fs . stat ( vscode . Uri . file ( path ) ) ;
53+ return path ;
54+ } catch ( _error : any ) {
55+ throw new NonReportableError ( `The Ruby LSP version manager is configured to be Mise, but ${ path } does not exist` ) ;
6056 }
61-
62- throw new NonReportableError (
63- `The Ruby LSP version manager is configured to be Mise, but could not find Mise installation. Searched in
64- ${ possiblePaths . join ( ", " ) } ` ,
65- ) ;
6657 }
6758}
0 commit comments