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

Crash on boot: can't find executable ruby-lsp for gem ruby-lsp #2607

Closed
tomocrafter opened this issue Sep 24, 2024 · 6 comments
Closed

Crash on boot: can't find executable ruby-lsp for gem ruby-lsp #2607

tomocrafter opened this issue Sep 24, 2024 · 6 comments
Assignees
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes

Comments

@tomocrafter
Copy link

tomocrafter commented Sep 24, 2024

Description

This is intended duplication issue of #1713, it seems another problem is causing prevent from booting.

The project which occuring this error have .bundle/config under project root directory with

---
BUNDLE_PATH: "vendor/bundle"

Ruby LSP Information

VS Code Version

1.93.1

Ruby LSP Extension Version

0.8.1

Ruby LSP Server Version

Unknown (vscode extension could not detected so I ran ruby-lsp --version and output was 0.18.1)

Ruby LSP Addons

Ruby Version

3.3.4

Ruby Version Manager

mise

Installed Extensions

Click to expand
  • yaml2json (0.0.6)
  • rails-db-schema (0.2.9)
  • vscode-apollo (2.3.2)
  • nord-visual-studio-code (0.19.0)
  • markdown-mermaid (1.25.0)
  • systemd-unit-file (1.0.6)
  • yash (0.2.9)
  • vscode-eslint (3.0.10)
  • vscode-deno (3.41.0)
  • vscode-sqlfluff (3.2.1)
  • gitlens (15.5.1)
  • vsc-material-theme-icons (3.8.8)
  • prettier-vscode (11.0.0)
  • hadolint (1.1.2)
  • dependi (0.7.10)
  • auto-rename-tag (0.1.10)
  • remotehub (0.64.0)
  • vscode-github-actions (0.26.5)
  • go (0.42.1)
  • gc-excelviewer (4.2.62)
  • vscode-graphql (0.12.0)
  • vscode-graphql-syntax (1.3.6)
  • vscode-settings-cycler (1.0.1)
  • vscode-ansi (1.1.7)
  • intellij-idea-keybindings (1.7.2)
  • haml (1.4.1)
  • ts-type-expand (1.2.0)
  • vscode-rdbg (0.2.2)
  • regexp-preview (0.1.5)
  • Kotlin (1.7.1)
  • rainbow-csv (3.12.0)
  • template-string-converter (0.6.1)
  • git-graph (1.30.0)
  • vscode-mjml (1.0.6)
  • vscode-scss (0.10.0)
  • vscode-docker (1.29.2)
  • csharp (2.45.25)
  • vscode-dotnet-runtime (2.1.6)
  • debugpy (2024.10.0)
  • isort (2023.10.1)
  • python (2024.14.1)
  • vscode-pylance (2024.9.2)
  • jupyter (2024.8.1)
  • jupyter-keymap (1.1.2)
  • jupyter-renderers (1.0.19)
  • remote-containers (0.384.0)
  • remote-ssh (0.114.3)
  • remote-ssh-edit (0.86.0)
  • vscode-remote-extensionpack (0.25.0)
  • azure-repos (0.40.0)
  • cmake-tools (1.19.52)
  • cpptools (1.21.6)
  • cpptools-extension-pack (1.3.0)
  • cpptools-themes (2.0.0)
  • hexeditor (1.10.0)
  • makefile-tools (0.11.13)
  • remote-explorer (0.4.3)
  • remote-repositories (0.42.0)
  • remote-server (1.5.2)
  • vsliveshare (1.0.5941)
  • sqltools (0.28.3)
  • sqltools-driver-pg (0.5.4)
  • prettify-ts (0.1.5)
  • bun-vscode (0.0.15)
  • coffeesense (1.15.0)
  • material-icon-theme (5.11.1)
  • vscode-react-refactor (1.1.3)
  • prisma (5.19.1)
  • quick-lint-js (3.2.0)
  • java (1.34.0)
  • rust-analyzer (0.3.2121)
  • ruby-extensions-pack (0.1.12)
  • ruby-lsp (0.8.1)
  • svelte-vscode (109.0.1)
  • even-better-toml (0.19.2)
  • cmake (0.0.17)
  • vscode-mdx (1.8.11)
  • errorlens (3.20.0)
  • vscode-lldb (1.10.0)
  • highlight-matching-tag (0.11.0)
  • vscode-gradle (3.16.4)
  • vscode-java-debug (0.58.0)
  • vscode-java-dependency (0.24.0)
  • vscode-java-pack (0.29.0)
  • vscode-maven (0.44.0)
  • vscode-icons (12.9.0)
  • JavaScriptSnippets (1.8.0)
  • vscode-caddyfile-syntax (1.0.4)

Ruby LSP Settings

Click to expand
Workspace
{}
User
{
  "enableExperimentalFeatures": false,
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "mise",
    "miseExecutablePath": "/usr/bin/mise"
  },
  "customRubyCommand": "",
  "formatter": "syntax_tree",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true
}

Bundler version is latest at this time: Bundler version 2.5.19

Reproduction steps

  1. Launch VSCode normally under project with code .
  2. ruby-lsp crashes 3 times with retry

Code snippet or error message

2024-09-24 11:23:43.510 [info] (<redacted>) Running command: `/usr/bin/mise x -- ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM:: YJIT), version: RUBY_VERSION }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /home/tomo/Repositories/<redacted> using shell: /usr/bin/fish
2024-09-24 11:23:44.530 [info] (<redacted>) Ruby LSP> Skipping custom bundle setup since /home/tomo/Repositories/<redacted>/.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...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-09-24 11:23:45.224 [info] (<redacted>) The Gemfile's dependencies are satisfied

2024-09-24 11:23:45.854 [info] (<redacted>) bundler: failed to load command: ruby-lsp (/home/tomo/.local/share/mise/installs/ruby/3.3.4/bin/ruby-lsp)
/home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/rubygems_integration.rb:265: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/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/rubygems_integration.rb:293:in `block in replace_bin_path'
	from /home/tomo/.local/share/mise/installs/ruby/3.3.4/bin/ruby-lsp:25:in `<top (required)>'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/cli/exec.rb:58:in `load'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/cli/exec.rb:23:in `run'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/cli.rb:455:in `exec'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/cli.rb:35:in `dispatch'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/cli.rb:29:in `start'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/exe/bundle:28:in `block in <top (required)>'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /home/tomo/Repositories/<redacted>/vendor/bundle/ruby/3.3.0/gems/bundler-2.5.19/exe/bundle:20:in `<top (required)>'
	from /home/tomo/.local/share/mise/installs/ruby/3.3.4/bin/bundle:25:in `load'
	from /home/tomo/.local/share/mise/installs/ruby/3.3.4/bin/bundle:25:in `<main>'

2024-09-24 11:23:45.883 [info] (<redacted>) [Error - 11:23:45 AM] Server process exited with code 1.
2024-09-24 11:23:45.884 [info] (<redacted>) [Error - 11:23:45 AM] Server initialization failed.
2024-09-24 11:23:45.884 [info] (<redacted>)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-09-24 11:23:45.884 [info] (<redacted>) [Error - 11:23:45 AM] Ruby LSP client: couldn't create connection to server.
2024-09-24 11:23:45.884 [info] (<redacted>)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-09-24 11:23:45.885 [error] (<redacted>) Error starting the server: Pending response rejected since connection got disposed
@tomocrafter tomocrafter added bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes labels Sep 24, 2024
@andyw8
Copy link
Contributor

andyw8 commented Sep 24, 2024

@tomocrafter are you intentionally setting BUNDLE_PATH for some reason? Does deleting that file solve the problem?

@vinistock
Copy link
Member

I wonder if this issue isn't the same as #2532. I've been reflecting on how to solve that one, but I haven't arrived at a decent approach just yet.

The BUNDLE_PATH setting should be fine and the fact that it's a local setting should have been fixed by #2535.

@tomocrafter
Copy link
Author

Thank you both for lookind into this issue.

@andyw8 This repository is work-related, and the config is shared by all members.

@vinistock The issue #2532 says "non-default version of bundler", How can I get the "default version of bundler" to test if this issue is related?

@vinistock
Copy link
Member

Honestly, I haven't been able to fix the problem because I also haven't been able to reproduce it properly. Every time I try require "bundler" requires exactly the right version of Bundler, which then doesn't require a restart and doesn't reproduce the issue.

If you want to take a stab at debugging this yourself (since you can reproduce it), you might be able to get a sense of what's going on by adding some $stderr.puts in our setup_bundler.rb logic and the exe/ruby-lsp executable.

I still need to investigate it further to fully understand how we can address the problem.

@tomocrafter
Copy link
Author

It is very strange, but I was debugging by adding puts to ruby-lsp source code and restarting ruby-lsp by running ruby-lsp multiple times and I did nothing but suddenly it started working somehow.
What I did is just adding bunch of puts to source code, and now it works if I reverted all debug puts. I have no idea.

@andyw8
Copy link
Contributor

andyw8 commented Oct 1, 2024

Thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

No branches or pull requests

3 participants