Skip to content

Commit

Permalink
Add support for configuring path to ASDF executable (#2695)
Browse files Browse the repository at this point in the history
* Add support for ASDF_ENV environment variable

* Fix lint erros

* Replace asdf dir variable with a extension setting

* Refact description message for asdf path

Co-authored-by: Vinicius Stock <[email protected]>

* Handle exception when user supplied path for asdf was not found

Co-authored-by: Vinicius Stock <[email protected]>

* Apply lint suggestions

---------

Co-authored-by: Vinicius Stock <[email protected]>
  • Loading branch information
srcid and vinistock authored Oct 18, 2024
1 parent 07b6dd8 commit bb336e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@
],
"default": "auto"
},
"asdfExecutablePath": {
"description": "The path to the asdf executable script, if not installed on one of the standard locations",
"type": "string"
},
"miseExecutablePath": {
"description": "The path to the Mise executable, if not installed in ~/.local/bin/mise",
"type": "string"
Expand Down
18 changes: 18 additions & 0 deletions vscode/src/ruby/asdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ export class Asdf extends VersionManager {
const scriptName =
path.basename(vscode.env.shell) === "fish" ? "asdf.fish" : "asdf.sh";

const config = vscode.workspace.getConfiguration("rubyLsp");
const asdfPath = config.get<string | undefined>(
"rubyVersionManager.asdfExecutablePath",
);

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

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

// Possible ASDF installation paths as described in https://asdf-vm.com/guide/getting-started.html#_3-install-asdf.
// In order, the methods of installation are:
// 1. Git
Expand Down

0 comments on commit bb336e5

Please sign in to comment.