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

VSCode extension checks multiple install locations for mise binary #2943

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

adam12
Copy link
Contributor

@adam12 adam12 commented Nov 30, 2024

Motivation

The installation path of Mise differs through the installation method chosen. Using Homebrew results in a path under /opt/homebrew where as the installation method from the Mise website is typically under $HOME/.local.

Implementation

When a custom mise path is not defined, 2 potential installation locations are tried instead.

Automated Tests

Skipping for now per discussion in PR.

Manual Tests

Extension manually started and observed Mise path of /opt/homebrew detected in logs.

2024-12-12 16:29:05.413 [info] (manager) Discovered version manager mise
2024-12-12 16:29:05.414 [info] (manager) Running command: `/opt/homebrew/bin/mise x -- ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /Users/adam/code/github.com/midstack/manager using shell: /opt/homebrew/bin/fish

Closes #2878

@adam12
Copy link
Contributor Author

adam12 commented Nov 30, 2024

I'd love some feedback/suggestions on how you'd like to see me approach testing this. Did you want me to set up a fake directory tree and confirm that a binary is found?

I didn't notice any other tests that are similar, and even throwing an error inside the existing code block seems to keep all the tests green, so I am presuming this function is mocked and not tested currently.

@vinistock
Copy link
Member

Yeah, this is currently mocked in other tests. I think it should be fine to leave this one without tests since it's the same approach of checking directories we're already using in other manager integrations.

@adam12
Copy link
Contributor Author

adam12 commented Dec 12, 2024

Poking around another file, I noticed that there is another instance where mise is checked in a specific path. Likely should be updated as well.

ruby-lsp/vscode/src/ruby.ts

Lines 411 to 421 in 896617a

try {
await vscode.workspace.fs.stat(
vscode.Uri.joinPath(
vscode.Uri.file(os.homedir()),
".local",
"bin",
"mise",
),
);
this.versionManager = ManagerIdentifier.Mise;
return;

@adam12 adam12 force-pushed the mise-multiple-locations branch from de53091 to 3314997 Compare December 12, 2024 02:40
vscode/src/ruby/mise.ts Outdated Show resolved Hide resolved
@vinistock vinistock added enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes labels Dec 12, 2024
@vinistock
Copy link
Member

Poking around another file, I noticed that there is another instance where mise is checked in a specific path. Likely should be updated as well.

Yeah, we need to refactor that manager detection logic at some point. Each version manager integration should have some function that will return true if it's detect to be installed and then we don't need to duplicate the logic. For now, feel free to duplicate it.

The installation path of Mise differs through the installation method
chosen. Using Homebrew results in a path under `/opt/homebrew` where as
the installation method from the Mise website is typically under
`$HOME/.local`.
@adam12 adam12 force-pushed the mise-multiple-locations branch from 3314997 to cefcb3c Compare December 12, 2024 21:20
@adam12 adam12 marked this pull request as ready for review December 12, 2024 21:33
@adam12 adam12 requested a review from a team as a code owner December 12, 2024 21:33
@adam12 adam12 requested a review from vinistock December 12, 2024 21:49
@adam12 adam12 changed the title Mise plugin checks multiple install locations for mise binary VSCode extension checks multiple install locations for mise binary Dec 12, 2024
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!

@vinistock vinistock merged commit 2e6d8d4 into Shopify:main Dec 13, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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.

Update autodetection of Mise in VSCode extension to support multiple locations
2 participants