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

Default Activation Not Installing ruby-lsp Gem #1764

Closed
1 task done
rex-smith opened this issue Jan 30, 2024 · 3 comments
Closed
1 task done

Default Activation Not Installing ruby-lsp Gem #1764

rex-smith opened this issue Jan 30, 2024 · 3 comments
Labels
bug Something isn't working Stale transferred This issue was transferred from vscode-ruby-lsp

Comments

@rex-smith
Copy link

Operating System

Ubuntu 20.04.5 LTS (WSL2)

Ruby version

3.1.2

Project has a bundle

  • Has bundle

Ruby version manager being used

asdf

Description

When I install the vscode extension, the Ruby LSP server crashes with the following information in the output tab:

2024-01-29 17:08:04.389 [info] (api) Trying to activate Ruby environment with command: /bin/bash -i -c 'asdf exec ruby -rjson -e "STDERR.printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, JSON.dump({ env: ENV.to_h, ruby_version: RUBY_VERSION, yjit: defined?(RubyVM::YJIT) }))"' inside directory: /home/user/project/api
2024-01-29 17:08:04.932 [info] (api) bundler: command not found: ruby-lsp
Install missing gem executables with `bundle install`

2024-01-29 17:08:04.943 [info] (api) [Error - 5:08:04 PM] Server initialization failed.
2024-01-29 17:08:04.943 [info] (api)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-01-29 17:08:04.943 [info] (api) [Info  - 5:08:04 PM] Connection to server got closed. Server will restart.
2024-01-29 17:08:04.943 [info] (api) true
2024-01-29 17:08:04.943 [info] (api) [Error - 5:08:04 PM] Ruby LSP client: couldn't create connection to server.
2024-01-29 17:08:04.943 [info] (api)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-01-29 17:08:04.948 [info] (api) [Error - 5:08:04 PM] Server process exited with code 127.
2024-01-29 17:08:05.064 [info] (api) bundler: command not found: ruby-lsp
Install missing gem executables with `bundle install`

When I install the ruby-lsp gem globally to try to avoid the error (which I know is not how I'm supposed to be installing it), I then get the following errors when I launch vscode:

2024-01-29 17:14:45.287 [info] (api) Trying to activate Ruby environment with command: /bin/bash -i -c 'asdf exec ruby -rjson -e "STDERR.printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, JSON.dump({ env: ENV.to_h, ruby_version: RUBY_VERSION, yjit: defined?(RubyVM::YJIT) }))"' inside directory: /home/username/project/api
2024-01-29 17:14:45.805 [info] (api) bundler: failed to load command: ruby-lsp (/home/username/.asdf/installs/ruby/3.1.2/bin/ruby-lsp)

2024-01-29 17:14:45.805 [info] (api) /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/rubygems_integration.rb:308:in `block in replace_bin_path': can't find executable ruby-lsp for gem ruby-lsp. ruby-lsp is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/rubygems_integration.rb:336:in `block in replace_bin_path'
	from /home/username/.asdf/installs/ruby/3.1.2/bin/ruby-lsp:25:in `<top (required)>'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/cli/exec.rb:58:in `load'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/cli/exec.rb:23:in `run'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/cli.rb:486:in `exec'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/cli.rb:31:in `dispatch'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/cli.rb:25:in `start'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/exe/bundle:48:in `block in <top (required)>'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
	from /home/username/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/exe/bundle:36:in `<top (required)>'
	from /home/username/.asdf/installs/ruby/3.1.2/bin/bundle:25:in `load'
	from /home/username/.asdf/installs/ruby/3.1.2/bin/bundle:25:in `<main>'

2024-01-29 17:14:45.816 [info] (api) [Error - 5:14:45 PM] Server initialization failed.
2024-01-29 17:14:45.816 [info] (api)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-01-29 17:14:45.816 [info] (api) [Info  - 5:14:45 PM] Connection to server got closed. Server will restart.
2024-01-29 17:14:45.816 [info] (api) true
2024-01-29 17:14:45.816 [info] (api) [Error - 5:14:45 PM] Ruby LSP client: couldn't create connection to server.
2024-01-29 17:14:45.816 [info] (api)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-01-29 17:14:45.825 [info] (api) [Error - 5:14:45 PM] Server process exited with code 1.
2024-01-29 17:14:46.004 [info] (api) bundler: failed to load command: ruby-lsp (/home/username/.asdf/installs/ruby/3.1.2/bin/ruby-lsp)

Finally, when I try to start the server by running ruby-lsp, I get the same "command not found" message if I have not installed the ruby-lsp gem globally, but once I install it globally myself, starting the server by running ruby-lsp works, just not in vscode.

@rex-smith rex-smith added the bug Something isn't working label Jan 30, 2024
@vinistock
Copy link
Member

Thank you for the bug report! I'm not sure what the issue here is, but here are some suggestions to try out:

  • Is asdf up to date?
  • Can you try updating Bundler to the latest version? You can update the locked Bundler version with bundle update --bundler

If neither works, I suspect it could be related to VS Code permissions. The LSP might be failing to create the .ruby-lsp directory or failing to run bundle install on the custom bundle.

Some users were discussing this #1586.

If you discover it is indeed a permission issue, please let us know which permission exactly you denied to VS Code. Full disk permission is definitely not needed (as I didn't grant that and can use the LSP just fine), so we've been unable to figure out exactly what causes the issue.

@rex-smith
Copy link
Author

Thanks for the response.

Asdf is up to date (v0.14.0), and after updating Bundler to the latest version (2.5.6), I'm still getting the same response as above. I'll look into the permissions and let you know if anything ends up working.

@st0012 st0012 transferred this issue from Shopify/vscode-ruby-lsp Mar 18, 2024
@st0012 st0012 added the transferred This issue was transferred from vscode-ruby-lsp label Mar 18, 2024
Copy link
Contributor

This issue is being marked as stale because there was no activity in the last 2 months

@github-actions github-actions bot added the Stale label May 18, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale transferred This issue was transferred from vscode-ruby-lsp
Projects
None yet
Development

No branches or pull requests

3 participants