Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize version manager script execution #2133

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Jun 5, 2024

Motivation

Closes #2114.

We were not passing the process environment or the shell detected by VS Code to version manager activation scripts.

However, it's becoming more evident that many version managers depend on certain environment variables to properly work (e.g.: $HOME). In addition to that, Rubygems itself depends on certain environment variables in order to define what the default and user gem paths are.

I think it's worth trying to standardize these script executions to always use the user's selected shell (which some version managers depend on) and make the execution inherit from process.env.

Notice that we're still not sourcing shell configuration scripts, since we moved away from that due to several integration issues.

Implementation

Created a convenience method runScript which always inserts the cwd, env and shell. Started using it everywhere we invoke manager integrations.

Small detail: vscode.env.shell returns an empty string rather than null in operating systems where that value is not set to anything. We do not want to pass an empty string to exec, but rather undefined or null.

Automated Tests

Adapted our tests.

Manual Tests

Essentially, launch the extension on this branch and ensure the server boots properly.

@vinistock vinistock added bugfix This PR will fix an existing bug vscode This pull request should be included in the VS Code extension's release notes labels Jun 5, 2024
@vinistock vinistock self-assigned this Jun 5, 2024
@vinistock vinistock requested a review from a team as a code owner June 5, 2024 14:55
@vinistock vinistock requested review from andyw8 and st0012 June 5, 2024 14:55
@vinistock vinistock force-pushed the vs/standardize_activation_exec branch from 5f9df41 to c966c46 Compare June 5, 2024 16:34
@vinistock
Copy link
Member Author

Since we now have the preview release available to us again, I'm going to ship one with this change to ensure we don't wreak havoc to activation with these changes.

@vinistock vinistock force-pushed the vs/standardize_activation_exec branch from c966c46 to a03a0e3 Compare June 7, 2024 15:42
@vinistock vinistock added bug Something isn't working and removed bug Something isn't working labels Jun 7, 2024
@vinistock vinistock merged commit 53cf57a into main Jun 7, 2024
34 checks passed
@vinistock vinistock deleted the vs/standardize_activation_exec branch June 7, 2024 16:03
@SeanSith
Copy link

SeanSith commented Jun 7, 2024

Any chance of getting this sort of syntax to work in the next update?

  "rubyLsp.bundleGemfile": "$HOME/.config/vscode/Gemfile",

Results in

2024-06-07 12:12:46.586 [info] (selectbreeders) Running command: `. /opt/homebrew/opt/asdf/libexec/asdf.sh && asdf exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/seansith/code/[project name redacted]/$HOME/.config/vscode using shell: /bin/zsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bundler: failed to load command: ruby-lsp (rbenv)
3 participants