Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.35k stars 121 forks source link

Set shell and env for ASDF activation #2006

Closed vinistock closed 1 day ago

vinistock commented 4 weeks ago

Motivation

Closes #1999, closes #1997, closes #2048, closes #2023

It might also do it for #2027, #1517 and #2020

Our ASDF integration was broken for two main reasons: ASDF depends on the user's shell and on a bunch of environment variables to properly activate. This is why we had to set the data dir manually, when in fact ASDF should be detecting that automatically.

Note that we may still need to offer settings for users to override ASDF_DIR and ASDF_DATA_DIR manually since ASDF does allow that and we're not sourcing their ~/.zshrc or ~/.bashrc files.

Implementation

  1. Started setting the shell to be vscode.env.shell, which should match what the user configured for VS Code's integrated terminal
  2. Started passing the process.env so that ASDF can use $HOME, $PATH and all other environment variables it needs to figure things out

I verified on a Linux machine that this works without having to specify ASDF_DIR or ASDF_DATA_DIR and without having to modify the PATH to include the shims directory (since ASDF is doing that on its own).

Automated Tests

Updated the tests.

Manual Tests

  1. Launch the extension in development mode on this branch
  2. Ensure the version manager is configured to be ASDF
  3. Ensure that the Ruby LSP server is launched properly using the expected Ruby version