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

Ruby LSP client: couldn't create connection to server #2936

Open
itinsley opened this issue Nov 29, 2024 · 11 comments
Open

Ruby LSP client: couldn't create connection to server #2936

itinsley opened this issue Nov 29, 2024 · 11 comments
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes

Comments

@itinsley
Copy link

Description

Ruby LSP Information

Ruby LSP Information

VS Code Version

1.95.3

Ruby LSP Extension Version

0.8.14

Ruby LSP Server Version

Unknown

Ruby LSP Addons

Ruby Version

3.3.5

Ruby Version Manager

asdf

Installed Extensions

Click to expand
  • copy-github-url (0.14.0)
  • ruby-lsp (0.8.14)
  • vscode-docker (1.29.3)
  • vscode-eslint (3.0.10)

Ruby LSP Settings

Click to expand
Workspace
{}
User
{
  "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": "auto"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "useLauncher": false,
  "featureFlags": {}
}

Reproduction steps

  1. Start VS Code following messages are in output window
024-11-29 14:53:32.142 [info] (leetcode) Checking if chruby is available on the path with command: /bin/zsh -i -c 'chruby --version'
2024-11-29 14:53:32.366 [info] (leetcode) Checking if rbenv is available on the path with command: /bin/zsh -i -c 'rbenv --version'
2024-11-29 14:53:32.549 [info] (leetcode) Checking if rvm is available on the path with command: /bin/zsh -i -c 'rvm --version'
2024-11-29 14:53:32.733 [info] (leetcode) Checking if asdf is available on the path with command: /bin/zsh -i -c 'asdf --version'
2024-11-29 14:53:32.943 [info] (leetcode) Discovered version manager asdf
2024-11-29 14:53:32.944 [info] (leetcode) Running command: `. /opt/homebrew/opt/asdf/libexec/asdf.sh && asdf exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /Users/iantinsley/work/Learn/leetcode using shell: /bin/zsh
2024-11-29 14:53:33.292 [info] (leetcode) /bin/sh: ruby-lsp: command not found

2024-11-29 14:53:33.293 [info] (leetcode) [Error - 14:53:33] Server process exited with code 127.
2024-11-29 14:53:33.293 [info] (leetcode) [Error - 14:53:33] Server initialization failed.
2024-11-29 14:53:33.293 [info] (leetcode)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-11-29 14:53:33.293 [info] (leetcode) [Error - 14:53:33] Ruby LSP client: couldn't create connection to server.
2024-11-29 14:53:33.294 [info] (leetcode)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-11-29 14:53:33.294 [error] (leetcode) Error starting the server: Pending response rejected since connection got disposed

Other Info

FWIW I have the following in ./zshrc

export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" . $(brew --prefix)/opt/asdf/libexec/asdf.sh

No .ruby-lsp folder

There is no .ruby-lsp file or folder

Standard Env?

Is there a standard favourable full dev environment settings to follow for a Mac? i.e. shell script/installer/version manager etc

@itinsley itinsley added bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes labels Nov 29, 2024
@andyw8
Copy link
Contributor

andyw8 commented Nov 29, 2024

👋 Can you share the output of this when run on the terminal:

/opt/homebrew/opt/asdf/libexec/asdf.sh && asdf exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'

@kylebragger
Copy link

Also getting this as of today. Output of the above:

RUBY_LSP_ACTIVATION_SEPARATOR{"env":{"RBENV_VERSION":"3.1.5","RBENV_GEMSET_ALREADY":"yes","TERM_PROGRAM":"Apple_Terminal","GEM_HOME":"/Users/kyle/.rbenv/versions/3.1.5/gemsets/ticketco-web","SHELL":"/bin/zsh","TERM":"xterm-256color","HOMEBREW_REPOSITORY":"/opt/homebrew","TMPDIR":"/var/folders/m1/d9028fz55lnbmv0grjj24s0w0000gn/T/","TERM_PROGRAM_VERSION":"453","TERM_SESSION_ID":"39DE51D2-018B-477D-8651-E79E330FD18F","ZSH":"/Users/kyle/.oh-my-zsh","USER":"kyle","LS_COLORS":"di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43","RBENV_ROOT":"/Users/kyle/.rbenv","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.s3Jkay7zZR/Listeners","PAGER":"less","RBENV_HOOK_PATH":"/Users/kyle/.rbenv/rbenv.d:/opt/homebrew/Cellar/rbenv/1.3.0/rbenv.d:/opt/homebrew/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks","LSCOLORS":"Gxfxcxdxbxegedabagacad","PATH":"/Users/kyle/.rbenv/versions/3.1.5/bin:/Users/kyle/.rbenv/versions/3.1.5/gemsets/global/bin:/Users/kyle/.rbenv/versions/3.1.5/gemsets/ticketco-web/bin:/opt/homebrew/Cellar/rbenv/1.3.0/libexec:/usr/local/sessionmanagerplugin/bin:/Users/kyle/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/go/bin","RBENV_ORIG_PATH":"/usr/local/sessionmanagerplugin/bin:/Users/kyle/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/go/bin","__CFBundleIdentifier":"com.apple.Terminal","PWD":"/Users/kyle/Code/hexagon-web","LANG":"en_US.UTF-8","XPC_FLAGS":"0x0","RBENV_SHELL":"zsh","XPC_SERVICE_NAME":"0","SHLVL":"1","HOME":"/Users/kyle","HOMEBREW_PREFIX":"/opt/homebrew","RBENV_DIR":"/Users/kyle/Code/hexagon-web","LESS":"-R","LOGNAME":"kyle","GEM_PATH":"/Users/kyle/.rbenv/versions/3.1.5/gemsets/ticketco-web:/Users/kyle/.rbenv/versions/3.1.5/gemsets/global:/Users/kyle/.rbenv/versions/3.1.5/lib/ruby/gems/3.1.0","INFOPATH":"/opt/homebrew/share/info:","HOMEBREW_CELLAR":"/opt/homebrew/Cellar","RUBYLIB":"/opt/homebrew/Cellar/rbenv/1.3.0/rbenv.d/exec/gem-rehash:","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0"},"yjit":false,"version":"3.1.5","gemPath":["/Users/kyle/.rbenv/versions/3.1.5/gemsets/ticketco-web","/Users/kyle/.rbenv/versions/3.1.5/gemsets/global","/Users/kyle/.rbenv/versions/3.1.5/lib/ruby/gems/3.1.0"]}RUBY_LSP_ACTIVATION_SEPARATOR

@itinsley
Copy link
Author

itinsley commented Dec 2, 2024

I got permission denied... not sure if the sh command output is of value? see below.

I'm happy to start again from scratch if there's a way to do this.

➜  work git:(main) ✗ /opt/homebrew/opt/asdf/libexec/asdf.sh && asdf exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'
zsh: permission denied: /opt/homebrew/opt/asdf/libexec/asdf.sh
➜  work git:(main) ✗ sudo /opt/homebrew/opt/asdf/libexec/asdf.sh && asdf exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'
sudo: /opt/homebrew/opt/asdf/libexec/asdf.sh: command not found
➜  work git:(main) ✗ sh /opt/homebrew/opt/asdf/libexec/asdf.sh && asdf exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'
RUBY_LSP_ACTIVATION_SEPARATOR{"env":{"PATH":"/Users/iantinsley/.asdf/installs/ruby/3.3.5/bin:/Users/iantinsley/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Applications/Postgres.app/Contents/Versions/latest/bin","TERM_PROGRAM":"Apple_Terminal","GEM_HOME":"/Users/iantinsley/.gem","ASDF_DIR":"/opt/homebrew/opt/asdf/libexec","TERM":"xterm-256color","SHELL":"/bin/zsh","HOMEBREW_REPOSITORY":"/opt/homebrew","TMPDIR":"/var/folders/52/pvl9flqd6gq9s47jsdpd6m2h0000gn/T/","TERM_PROGRAM_VERSION":"455","ASDF_DEFAULT_TOOL_VERSIONS_FILENAME":".tool-versions","TERM_SESSION_ID":"568B170F-B731-4BB3-ADAB-03CA3D499AFE","ZSH":"/Users/iantinsley/.oh-my-zsh","USER":"iantinsley","LS_COLORS":"di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.wReIIoH3gt/Listeners","PAGER":"less","LSCOLORS":"Gxfxcxdxbxegedabagacad","RUBY_CONFIGURE_OPTS":"--with-openssl-dir=/opt/homebrew/opt/[email protected]","LaunchInstanceID":"57292604-EC38-4755-8EB3-98F7798A218F","__CFBundleIdentifier":"com.apple.Terminal","PWD":"/Users/iantinsley/work/Learn/leetcode","ASDF_CONFIG_FILE":"/Users/iantinsley/.asdfrc","LANG":"en_AU.UTF-8","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"0","HOME":"/Users/iantinsley","SHLVL":"1","HOMEBREW_PREFIX":"/opt/homebrew","ASDF_DATA_DIR":"/Users/iantinsley/.asdf","LESS":"-R","LOGNAME":"iantinsley","PSQL_PATH":"/Applications/Postgres.app/Contents/Versions/latest/bin","INFOPATH":"/opt/homebrew/share/info:","HOMEBREW_CELLAR":"/opt/homebrew/Cellar","RUBYLIB":"/Users/iantinsley/.asdf/plugins/ruby/rubygems-plugin","SECURITYSESSIONID":"186b1","PYTHON":"python3","__CF_USER_TEXT_ENCODING":"0x1F5:0:15"},"yjit":false,"version":"3.3.5","gemPath":["/Users/iantinsley/.gem/ruby/3.3.0","/Users/iantinsley/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0","/Users/iantinsley/.gem"]}RUBY_LSP_ACTIVATION_SEPARATOR%     ```

@ske7
Copy link

ske7 commented Dec 2, 2024

Absolutely the same issue got today
ruby lsp 0.8.15
ruby 3.2.3 on windows

2024-12-02 23:57:49.816 [info] Discovered version manager rubyInstaller
2024-12-02 23:57:49.817 [info] Discovered Ruby version 3.2.3 from c:\Projects\rails-dev-box\rails\.ruby-version
2024-12-02 23:57:49.832 [info] Discovered Ruby installation at c:\Ruby32-x64\bin\ruby
2024-12-02 23:57:49.832 [info]  Running command: `c:\Ruby32-x64\bin\ruby -W0 -e 'user_dir = Gem.user_dir;paths = Gem.path;if paths.length > 2;  paths.delete(Gem.default_dir);  paths.delete(Gem.user_dir);  if paths[0];    user_dir = paths[0] if Dir.exist?(paths[0]);  end;end;newer_gem_home = File.join(File.dirname(user_dir), "3.2.3");gems = (Dir.exist?(newer_gem_home) ? newer_gem_home : user_dir);STDERR.print([Gem.default_dir, gems, !!defined?(RubyVM::YJIT), RUBY_VERSION].join("RUBY_LSP_ACTIVATION_SEPARATOR"))'` in c:\Projects\rails-dev-box\rails
2024-12-02 23:57:50.124 [info]  Activated Ruby environment: defaultGems=c:/Ruby32-x64/lib/ruby/gems/3.2.0 gemHome=C:/Users/Demi/.gem/ruby/3.2.0 yjit=false
2024-12-02 23:57:51.648 [info]  ruby.exe: warning: Ruby was built without YJIT support. You may need to install rustc to build Ruby with YJIT.
2024-12-02 23:57:52.432 [info]  C:/Users/Demi/.gem/ruby/3.2.0/gems/ruby-lsp-0.22.1/exe/ruby-lsp:69:in `exec': Exec format error - C:/Users/Demi/.gem/ruby/3.2.0/gems/ruby-lsp-0.22.1/exe/ruby-lsp-launcher (Errno::ENOEXEC)
	from C:/Users/Demi/.gem/ruby/3.2.0/gems/ruby-lsp-0.22.1/exe/ruby-lsp:69:in `<top (required)>'
	from C:/Users/Demi/.gem/ruby/3.2.0/bin/ruby-lsp:32:in `load'
	from C:/Users/Demi/.gem/ruby/3.2.0/bin/ruby-lsp:32:in `<main>'
2024-12-02 23:57:52.445 [info]  [Error - 11:57:52 PM] Server initialization failed.
2024-12-02 23:57:52.445 [info]    Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-12-02 23:57:52.445 [info]  [Error - 11:57:52 PM] Ruby LSP client: couldn't create connection to server.
2024-12-02 23:57:52.445 [info]    Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-12-02 23:57:52.445 [error]  Error starting the server: Pending response rejected since connection got disposed
2024-12-02 23:57:52.446 [info]  [Error - 11:57:52 PM] Server process exited with code 1.
2024-12-02 23:59:02.701 [info]  [Error - 11:59:02 PM] Connection to server got closed. Server will not be restarted.

Before addon version update, just on Friday it was working well

@ske7
Copy link

ske7 commented Dec 2, 2024

I set launcher feature in settings.json to false and now it started successfully

  "rubyLsp.featureFlags": {
    "launcher": false,
    "all": true
  }

We should blame this #2914

@andyw8
Copy link
Contributor

andyw8 commented Dec 2, 2024

@ske7 thank you for reporting.

We're doing a gradual rollout of the Launcher feature to 5% of users but it looks like there may be some problems.

For the others in this thread experience errors, please try the above solution of disabling launcher in the config.

@itinsley
Copy link
Author

itinsley commented Dec 2, 2024

I tried these changes and still get:

/bin/sh: ruby-lsp: command not found

@hughevans
Copy link

hughevans commented Dec 3, 2024

Also, if you receive an error like this:

2024-12-02 14:00:20.471 [info] (perform-core) <internal:/nix/store/qr1qhf6x5k4j1apijs1hpml749ahz9fz-ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require': cannot load such file -- ruby_lsp/load_sorbet (LoadError)
	from <internal:/nix/store/qr1qhf6x5k4j1apijs1hpml749ahz9fz-ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from /Users/hugh.evans/Code/.devbox/virtenv/ruby/gems/ruby-lsp-0.22.1/exe/ruby-lsp-launcher:88:in `<main>'

Turn off the launcher feature flag:

  "rubyLsp.featureFlags": {
    "launcher": false,
  }

@itinsley
Copy link
Author

Any progress on this? As I said before, is there anything in my setup which is likely to cause the problem? Should I try again without ASDF or brew or zsh? Thanks!

@vinistock
Copy link
Member

Unfortunately, two separate things got mixed into this same issue. The launcher mode issues are not related to the original author's problem, so please report any of those issues here #2977.

@itinsley concerning your problem, do you happen to have any Bundler settings (either user or project level)? Any ASDF customizations?

@dpaluy
Copy link

dpaluy commented Dec 16, 2024

I'm getting the same error on Mac OS 15.1.1 with asdf

Error: zsh: permission denied: /opt/homebrew/opt/asdf/libexec/asdf.sh

I also tried to define a custom command:

{
  "rubyLsp.featureFlags": {
    "all": true,
    "launcher": false
  },
  "rubyLsp.formatter": "rubocop",
  "rubyLsp.addonSettings": {},
  "rdbg.rubyVersionManager": "asdf",
  "rubyLsp.customRubyCommand": "asdf exec ruby"
}

The VS Code output:

Running command: `. /opt/homebrew/opt/asdf/libexec/asdf.sh && asdf exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /Users/david/projects/su-backend using shell: /opt/homebrew/bin/zsh
2024-12-16 14:21:39.894 [info] No preset version installed for command ruby-lsp
Please install a version by running one of the following:

asdf install ruby 3.3.6

or add one of the following versions in your config file at /Users/david/.tool-versions

2024-12-16 14:21:39.905 [info] (su-backend) ruby 2.7.5

It ignores my local settings while loading the RubyLSP

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

7 participants