@@ -34,8 +34,8 @@ export class Asdf extends VersionManager {
3434 }
3535
3636 static async detect (
37- _workspaceFolder : vscode . WorkspaceFolder ,
38- _outputChannel : WorkspaceChannel ,
37+ workspaceFolder : vscode . WorkspaceFolder ,
38+ outputChannel : WorkspaceChannel ,
3939 ) : Promise < DetectionResult > {
4040 // Check for v0.16+ executables first
4141 const executablePaths = Asdf . getPossibleExecutablePaths ( ) ;
@@ -51,6 +51,12 @@ export class Asdf extends VersionManager {
5151 return { type : "path" , uri : scriptResult } ;
5252 }
5353
54+ // check on PATH
55+ const toolExists = await VersionManager . toolExists ( "asdf" , workspaceFolder , outputChannel ) ;
56+ if ( toolExists ) {
57+ return { type : "semantic" , marker : "asdf" } ;
58+ }
59+
5460 return { type : "none" } ;
5561 }
5662
@@ -63,24 +69,31 @@ export class Asdf extends VersionManager {
6369 asdfUri = vscode . Uri . file ( configuredPath ) ;
6470 } else {
6571 const result = await Asdf . detect ( this . workspaceFolder , this . outputChannel ) ;
72+
6673 if ( result . type === "path" ) {
6774 asdfUri = result . uri ;
75+ } else if ( result . type === "semantic" ) {
76+ // Use ASDF from PATH
77+ } else {
78+ throw new Error (
79+ `Could not find ASDF installation. Searched in ${ [
80+ ...Asdf . getPossibleExecutablePaths ( ) ,
81+ ...Asdf . getPossibleScriptPaths ( ) ,
82+ ] . join ( ", " ) } `,
83+ ) ;
6884 }
6985 }
7086
71- if ( ! asdfUri ) {
72- throw new Error (
73- `Could not find ASDF installation. Searched in ${ [
74- ...Asdf . getPossibleExecutablePaths ( ) ,
75- ...Asdf . getPossibleScriptPaths ( ) ,
76- ] . join ( ", " ) } `,
77- ) ;
78- }
87+ let baseCommand : string ;
7988
80- const asdfPath = asdfUri . fsPath ;
81- // If there's no extension name, then we are using the ASDF executable directly. If there is an extension, then it's
82- // a shell script and we have to source it first
83- const baseCommand = path . extname ( asdfPath ) === "" ? asdfPath : `. ${ asdfPath } && asdf` ;
89+ if ( asdfUri ) {
90+ const asdfPath = asdfUri . fsPath ;
91+ // If there's no extension name, then we are using the ASDF executable directly. If there is an extension, then it's
92+ // a shell script and we have to source it first
93+ baseCommand = path . extname ( asdfPath ) === "" ? asdfPath : `. ${ asdfPath } && asdf` ;
94+ } else {
95+ baseCommand = "asdf" ;
96+ }
8497
8598 const parsedResult = await this . runEnvActivationScript ( `${ baseCommand } exec ruby` ) ;
8699
0 commit comments