ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Implement ASDF as a manager object

Open vinistock opened this issue 1 year ago • 3 comments

Motivation

Migrate ASDF to the manager object implementation. This is the last version manager to migrate.

The only parts left of the Ruby activation restructuring is handling no version manager, custom Ruby activation and allowing manual selection of the Ruby installation.

Implementation

ASDF activation is similar to Rbenv. The main difference is that the asdf.sh file is not an executable and can only be sourced to allow invoking asdf.

In addition to that, the asdf documentation lists a number of different installation alternatives, all of which end up with the asdf.sh script in a different file path. I listed all possible paths described in the docs and we search for the script in those paths.

Then we source the script and use asdf exec ruby to run the activation script in the context of the activated Ruby. Like Rbenv, ASDF doesn't set GEM_HOME or GEM_PATH so we need to do that ourselves.

I tested this manually on a Spin instance where I installed ASDF.

Automated Tests

Added a test.

Manual Tests

  1. Start the extension on this branch
  2. Open a project with a .tools-version file
  3. Verify the Ruby LSP boots properly using the specified Ruby version

vinistock avatar Mar 27 '24 18:03 vinistock

ASDF also supports .ruby-version, will that work here?

andyw8 avatar Mar 27 '24 19:03 andyw8

I use asdf on my personal machine so can try this later.

andyw8 avatar Mar 27 '24 19:03 andyw8

ASDF also supports .ruby-version, will that work here?

It should. We're invoking the asdf executable, so it should handle whatever ASDF handles in the terminal too.

I use asdf on my personal machine so can try this later.

Awesome! Please report back if everything is working.

vinistock avatar Mar 27 '24 19:03 vinistock