ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Unable to start Ruby LSP server when using a custom BUNDLE_PATH

Open wamonroe opened this issue 3 years ago • 3 comments

Operating System

macOS 13.4.1

Ruby version

3.2.2

Project has a bundle

  • [X] Has bundle

Ruby version manager being used

asdf

Description

With the latest update to the extension (0.4.3) the Ruby LSP server crashes on startup IF I have have a custom BUNDLE_PATH set for bundler. If I revert to the previous version (0.3.7) or I remove the custom path setting the issue goes away.

You can reproduce the issue by starting with a fresh Ruby install (without any additional gems installed), setting your local bundle path for an existing project to something like ".bundle", e.g. bundle config --local path .bundle, running bundle install and then opening the project in VS Code.

Here is the output from my VS Code. The output below is from a test I ran on Ruby 3.2.0, but the issue persists even with Ruby 3.2.2.:

Ruby LSP> Skipping custom bundle setup since /Users/alex/Code/my-project/.ruby-lsp/Gemfile.lock already exists and is up to date
Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies....
# ...
Using ruby-lsp 0.7.6
Bundler attempted to update ruby-lsp but its version stayed the same
Bundler attempted to update debug but its version stayed the same
Bundle updated!
bundler: failed to load command: ruby-lsp (/Users/alex/.asdf/installs/ruby/3.2.0/bin/ruby-lsp)
/Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/definition.rb:481:in `materialize': Could not find rails-7.0.4.2, sqlite3-1.6.0-arm64-darwin, bootsnap-1.16.0, bootstrap-5.2.3, devise-4.8.1, mailgun-ruby-1.2.6, puma-6.0.2, react-rails-2.6.2, redis-5.0.6, sassc-rails-2.1.2, simple_form-5.2.0, sprockets-4.2.0, turbolinks-5.2.1, uglifier-4.2.0, webpacker-5.4.4, pry-0.14.2, byebug-11.1.3, web-console-4.2.0, rspec-rails-6.0.1, rspec_junit_formatter-0.6.0, ruby-lsp-0.7.6, debug-1.8.0, actioncable-7.0.4.2, actionmailbox-7.0.4.2, actionmailer-7.0.4.2, actionpack-7.0.4.2, actiontext-7.0.4.2, actionview-7.0.4.2, activejob-7.0.4.2, activemodel-7.0.4.2, activerecord-7.0.4.2, activestorage-7.0.4.2, activesupport-7.0.4.2, railties-7.0.4.2, msgpack-1.6.0, autoprefixer-rails-10.4.7.0, popper_js-2.11.6, bcrypt-3.1.18, orm_adapter-0.5.0, responders-3.1.0, warden-1.2.9, rest-client-2.1.0, nio4r-2.5.8, babel-transpiler-0.7.0, connection_pool-2.3.0, execjs-2.8.1, tilt-2.0.11, redis-client-0.12.1, sassc-2.4.0, sprockets-rails-3.4.2, concurrent-ruby-1.2.0, rack-2.2.6.4, turbolinks-source-5.2.0, rack-proxy-0.7.6, semantic_range-3.0.0, coderay-1.1.3, method_source-1.0.0, bindex-0.8.1, rspec-core-3.12.1, rspec-expectations-3.12.2, rspec-mocks-3.12.3, rspec-support-3.12.0, language_server-protocol-3.17.0.3, sorbet-runtime-0.5.10950, syntax_tree-6.1.1, irb-1.7.4, reline-0.3.7, websocket-driver-0.7.5, mail-2.8.1, net-imap-0.3.4, net-pop-0.1.2, net-smtp-0.3.3, rails-dom-testing-2.0.3, rack-test-2.0.2, rails-html-sanitizer-1.5.0, globalid-1.1.0, nokogiri-1.14.3-arm64-darwin, builder-3.2.4, erubi-1.12.0, marcel-1.0.2, mini_mime-1.1.2, i18n-1.12.0, minitest-5.17.0, tzinfo-2.0.6, rake-13.0.6, thor-1.2.1, zeitwerk-2.6.6, http-accept-1.7.0, http-cookie-1.0.5, mime-types-3.4.1, netrc-0.11.0, babel-source-5.8.35, ffi-1.15.5, diff-lcs-1.5.0, prettier_print-1.2.1, websocket-extensions-0.1.5, loofah-2.19.1, domain_name-0.5.20190701, mime-types-data-3.2022.0105, crass-1.0.6, unf-0.1.4, unf_ext-0.0.8.2 in any of the sources (Bundler::GemNotFound)
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/definition.rb:190:in `specs'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/definition.rb:238:in `specs_for'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/runtime.rb:18:in `setup'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler.rb:151:in `setup'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/setup.rb:20:in `block in <top (required)>'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/ui/shell.rb:136:in `with_level'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/ui/shell.rb:88:in `silence'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/setup.rb:20:in `<top (required)>'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/cli/exec.rb:56:in `require_relative'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/cli/exec.rb:56:in `kernel_load'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/cli.rb:483:in `exec'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/cli.rb:31:in `dispatch'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/cli.rb:25:in `start'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/exe/bundle:48:in `block in <top (required)>'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
	from /Users/alex/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.3.11/exe/bundle:36:in `<top (required)>'
	from /Users/alex/.asdf/installs/ruby/3.2.0/bin/bundle:25:in `load'
	from /Users/alex/.asdf/installs/ruby/3.2.0/bin/bundle:25:in `<main>'
[Error - 8:51:52 AM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 8:51:52 AM] Connection to server got closed. Server will restart.
true
[Error - 8:51:52 AM] Ruby LSP client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 

wamonroe avatar Aug 07 '23 13:08 wamonroe

Thanks for the bug report!

Do you have any other bundler configurations other than BUNDLE_PATH?

vinistock avatar Aug 08 '23 19:08 vinistock

Thanks for responding!

Yeah, I had the following settings in my global bundle configuration as well:

BUNDLE_GEM__TEST: "minitest"
BUNDLE_GEM__CI: "false"
BUNDLE_GEM__MIT: "true"
BUNDLE_GEM__COC: "false"
BUNDLE_GEM__CHANGELOG: "true"
BUNDLE_GEM__LINTER: "standard"

But I can still reproduce the issue after removing those.

wamonroe avatar Aug 08 '23 19:08 wamonroe

Fixed by https://github.com/Shopify/ruby-lsp/pull/890.

vinistock avatar Aug 14 '23 19:08 vinistock