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

Run bundle install if Gemfile but no Gemfile.lock #1944

Open
Earlopain opened this issue Apr 16, 2024 · 4 comments
Open

Run bundle install if Gemfile but no Gemfile.lock #1944

Earlopain opened this issue Apr 16, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Earlopain
Copy link
Contributor

Description

Reproduction steps

Check out a fresh copy of a repo with Gemfile.lock in .gitignore (rubocop/rubocop for example).

The LSP starting will first show a notice about mulitroot workspaces and after discarding that refuse to start with the following:

Project contains a Gemfile, but no Gemfile.lock. Run bundle install to lock gems and restart the server

Would it make sense to automatically run bundle install for the user in these cases? This would probably require explicit user confirmation, similarly to how VSCode asks about trusted folders. Gems may execute arbitrary commands during installation (I think, especially C extensions during compilation). Perhaps the confirmation of VSCode is already enough, if the extension isn't opting in to trusted mode, https://code.visualstudio.com/docs/editor/workspace-trust. I believe that is the case currently, however looks to be vscode specific and not part of the LSP protocol.

@Earlopain Earlopain added the bug Something isn't working label Apr 16, 2024
@andyw8
Copy link
Contributor

andyw8 commented Apr 16, 2024

Similarly, this also happens if you use bundle gem when creating a new gem, since there's initially no Gemfile.lock.

@vinistock
Copy link
Member

After discussing this with the team, our general sentiment is that the LSP should not run bundle install automatically on a non-locked project. Having the bundle locked is fundamental for anything to work really. Without that, you're unable to run tests, run linters or really do much.

That said, we also believe that the experience is currently quite odd for that scenario. We are only checking if the lockfile exists and then we display a warning including information about multi-root workspaces.

We should definitely include a check to see if a Gemfile or gems.rb file exists and then we can definitely offer from the VS Code extension to first run bundle install on the project's bundle before trying to launch the language server. How does that sound?

@Earlopain
Copy link
Contributor Author

LSP should not run bundle install automatically on a non-locked project

We should definitely include a check to see if a Gemfile or gems.rb file exists and then we can definitely offer from the VS Code extension to first run bundle install

These two seem to be in conflict unless the important part here is "automatically", as in without user interaction. Offering to run bundle install for the user sounds perfectly fine and is one possible solution I was writing about.

Right now you can open a project, ruby-lsp will show some signs of life, and then just not work. That is my main gripe I think.

@vinistock
Copy link
Member

Yes, indeed the point of discussing was the automatic aspect. Because we actually run bundle install only for the custom bundle under .ruby-lsp, which would create .ruby-lsp/Gemfile.lock, but no top level lockfile - which can be a bit weird.

We should definitely show a message and give the chance for the user to run bundle install if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants