Skip to content

gem install fails if system installation directory is read-only #1791

@kepstin

Description

@kepstin

Operating System

Exherbo Linux

Ruby version

3.0

Project has a bundle

  • Has bundle

Ruby version manager being used

no manager

Description

Using extension version 0.4.3. This is a regression from version 0.3.7. This issue appears to be related to #1640

I was using ruby-lsp with my operating system provided ruby, rather than ruby installed using a separate version manager. As a result, the standard gem installation directory is a system directory which is not writable by my user, and the extension initialization in 0.4.3 fails with the following error message:

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/x86_64-pc-linux-gnu/lib/ruby/gems/3.0 directory.

This is expected; when using the system ruby, any extra per-user gems outside of bundle need to be installed somewhere else. But if I manually install the ruby-lsp gem with the command gem install --user-install ruby-lsp to try to work around this problem, gem prints this warning:

WARNING: You don't have /home/kepstin/.local/share/gem/ruby/3.0/bin in your PATH, gem executables will not run.

and indeed, the extension fails to start ruby-lsp:

[Error - 15:51:26] Ruby LSP client: couldn't create connection to server.
Launching server using command ruby-lsp failed. Error: spawn ruby-lsp ENOENT
Error restarting the server: undefined

But I don't want to install extra ruby gems in my "user-install" directory anyways, I'd prefer to have them privately installed in each project dir… so I tried to use the "Bundle Gemfile" configuration provided to replicate the behaviour of 0.3.7: I set "rubyLsp.bundleGemfile": ".ruby-lsp/Gemfile" and created the following Gemfile there:

source 'https://rubygems.org'
gem 'ruby-lsp'

I ran bundle config set --local path vendor/bundle in that directory to tell bundler to install the gems in that directory rather than in a system location, and did a bundle install.

But as far as I can tell, this configuration is non-functional; even with the Bundle Gemfile configuration set, the extension is still printing the same error message saying that it's trying to run gem install ruby-lsp. There's no code in the installOrUpdateServer function to handle checking if ruby-lsp is installed in a bundle environment, and also no code in start to handle starting ruby-lsp using bundler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp-wantedExtra attention is neededpinnedThis issue or pull request is pinned and won't be marked as stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions