-
Notifications
You must be signed in to change notification settings - Fork 155
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
Installation of gem ruby-lsp fails #1745
Comments
Is it this devcontainer repo? https://github.com/luizkowalski/devcontainer-rails/ |
@andyw8 No. I'm using https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres. I use this directly through VS Code. I create a new workspace, open the command palette, and use Dev Containers: Add Dev Container Configuration Files. I select the "Ruby on Rails & Postgres" configuration files, which are maintained by devcontainers. There are other options. There is a Ruby option also maintained by devcontainers along with a Ruby on Rails that is community maintained. I can experiment with these to see if they also have the issue. I don't know if this plugin is included out-of-the-box in the other configuration files, though. I wonder if this is partially related to devcontainers/templates#188. However, even setting the |
You said it's "installed out-of-the-box in the Ruby on Rails & Postgres devcontainer" but I can't see any reference to Ruby LSP in there. 🤔 |
It's indirectly installed. The Ruby on Rails & Postgres container is built on the Ruby container image. The Ruby Container image includes the Ruby feature: https://github.com/devcontainers/images/blob/main/src/ruby/.devcontainer/devcontainer.json#L14 The Ruby feature installs Ruby LSP: https://github.com/devcontainers/features/blob/main/src/ruby/devcontainer-feature.json#L25 I suspect that this issue would also affect the use of the Ruby container image directly, but I could test that later. |
Let's try to understand why we're trying install the Can you explain in more detail what your RVM set up is? Are you using gemsets or configuring a BUNDLE_PATH? If you had to install a gem without bundler by doing I believe it might be related to #1791. Doing |
@vinistock I have no idea what the RVM setup is. I'm using VS Code to create new devcontainer configuration files using the "Ruby on Rails & Postgres" configuration. When I connect to that container, I get the provided error message. I believe that I should be able to use VS Code to create a new devcontainer configuration, create a devcontainer, and connect to it with no errors. That is not the case right now, but the only errors that I've seen so far are from ruby-lsp. This could be related to devcontainers/templates#188. It doesn't make much sense to install any version manager on a devcontainer by default. I don't know if the devcontainer team making those proposed changes would resolve the issue or not. It's not clear to me if this is a ruby-lsp problem or a devcontainer problem. The only error messages were explicitly about ruby-lsp, so I started here. |
Well, it could be a combination of both. We already know from #1791 that we need to improve how we handle the global installation if we don't have permissions for the default path, so that part of the issue is on the Ruby LSP side. Whether the devcontainer should have installed RVM or not and whether the configuration for RVM is correct is the second part of the issue which is on the container side. From the container's perspective, a possible solution could be to create a gemset where the user has permissions to install things. But it depends on how folks wanted the container to be configured. The Ruby LSP automatically detects which version manager is installed to be able to select the right Ruby version to run. If you force the manager to be // Your VS Code JSON settings
{
"rubyLsp.rubyVersionManager": "none"
} |
@vinistock I will experiment with the gemset and the version manager configuration over the next couple of days and follow-up here. I also want to experiment with starting with the base Ruby container and see if the same problems persist there. |
This helped me get past the issue for now: adding
|
@kmayer Yes. You're right. I just checked the permissions on RVM's I checked using the base Ruby devcontainer configuration. There, everything in I'm wondering if the better solution wouldn't be to use Ruby as the devcontainer. Or even using Alpine as the base devcontainer. From one of these, it would be possible to built it up to include Rails and Postgres (or an alternative database) without a lot of headache. It's quite unfortunate that official devcontainers are installing functionality in a way that causes them to be broken. What was supposed to be an easy "spin up a devcontainer with the exact config I need" wasn't that easy. Someone with more knowledge of ruby-lsp should confirm, but this is looking increasingly like a devcontainer problem. |
The thing that is triggering And it seems that the devcontainer only has the default RVM gemset, which doesn't give you permissions to install there. Are there not other gemsets in the container? How do people run I think it's worth understanding if the container should be coming with a user owned gemset. |
@vinistock I don't follow. In terms of running my application, I haven't even gotten to the point where I would need to |
I'm trying to understand the differences between a developer installing gems regularly (using So you always have That might be the reason, in which case we'll need to think about how we can improve this in the LSP. To avoid forcing people to add the But if the only place you have permissions to install gems is under |
Considering that this gem works in the Ruby devcontainer but not the Ruby on Rails & Postgres devcontainer, I don't think it's something that you're doing. I need to dig into the installation scripts, but it looks like in the Ruby on Rails & Postgres devcontainer, something (unclear if it's RVM, the default Ruby installation, gems, or a combination of those) are being installed by the root user rather than the vscode user. This is not an error in the Ruby devcontainer, where the RVM directories are all owned by the vscode user. The important thing is that I'm not installing ruby-lsp. That's handled by the Ruby devcontainer feature file installing the VS Code extension (see https://github.com/devcontainers/features/blob/main/src/ruby/devcontainer-feature.json#L25). However, with the RVM installation being owned by root and this being run by the vscode user, there aren't permissions. I'm pretty sure the permissions are mangled by one of the scripts in the Ruby on Rails & Postgres devcontainer, since the only error that I'm getting in the Ruby devcontainer is the fact that my linter isn't installed. That error goes away after changing the configuration or installing a linter, though. The question for me, though, is how much time I want to invest in this Ruby on Rails & Postgres container. The answer is probably "not much", especially if the Ruby devcontainer doesn't have these issues and it's trivial to install the Postgres client and use a compose file to include the Postgres container. I think I want to pivot and see if getting the Ruby container set up for my project is easy enough and also results in a working ruby-lsp. |
I made the changes to the Ruby on Rails & Postgres devcontainer, which resolved this issue. The changes have been merged into the devcontainer repository. |
Thank you @ThomasOwens! |
Operating System
Windows / devcontainer
Ruby version
3.2
Project has a bundle
Ruby version manager being used
rvm
Description
I created a new Ruby on Rails & Postgres Dev Container using VS Code, connected to it, and am attempting to start a new project.
After connecting to the devcontainer, the following error appears:
Failed to setup the bundle: Command failed: gem install ruby-lsp ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/local/rvm/gems/default directory. /usr/local/lib/ruby/3.2.0/rubygems/installer.rb:712:in
verify_gem_home' /usr/local/lib/ruby/3.2.0/rubygems/installer.rb:902:in
pre_install_checks' /usr/local/lib/ruby/3.2.0/rubygems/installer.rb:302:ininstall' /usr/local/lib/ruby/3.2.0/rubygems/resolver/specification.rb:104:in
install' /usr/local/lib/ruby/3.2.0/rubygems/request_set.rb:194:inblock in install' /usr/local/lib/ruby/3.2.0/rubygems/request_set.rb:182:in
each' /usr/local/lib/ruby/3.2.0/rubygems/request_set.rb:182:ininstall' /usr/local/lib/ruby/3.2.0/rubygems/commands/install_command.rb:214:in
install_gem' /usr/local/lib/ruby/3.2.0/rubygems/commands/install_command.rb:230:inblock in install_gems' /usr/local/lib/ruby/3.2.0/rubygems/commands/install_command.rb:223:in
each' /usr/local/lib/ruby/3.2.0/r...I was under the impression that this was related to #1572, Shopify/vscode-ruby-lsp#664, #1787, Shopify/vscode-ruby-lsp#750 or one of the related linked issues/PRs. However, both VS Code and the Ruby LSP plugin are fully updated and this problem persists even though these issues have been marked as resolved. It's not clear if there's a regression or this is a different issue.
Since this plugin is installed out-of-the-box in the Ruby on Rails & Postgres devcontainer, I would not expect errors when creating and connecting to this devcontainer.
The text was updated successfully, but these errors were encountered: