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

Cannot start ruby-lsp with sublime text 4 #2842

Open
leewaa opened this issue Nov 9, 2024 · 1 comment
Open

Cannot start ruby-lsp with sublime text 4 #2842

leewaa opened this issue Nov 9, 2024 · 1 comment
Labels
bug Something isn't working help-wanted Extra attention is needed non-vscode

Comments

@leewaa
Copy link

leewaa commented Nov 9, 2024

Description

Reproduction steps

I cannot get ruby-lsp to work. IT fails to start, and judging from the trouble shoot output, there is something wrong with the environment it is running in, even though it seems to have the correct ENV with the paths set correctly. From the paths alone it looks like it uses the correct ruby, however the stack trace indicates is is trying to use ruby 2.6 somehow 😵‍💫??

Main points:

  • Using sublime text version 4180

  • Config:

    "ruby-lsp": {
      "enabled": true,
      "command": [
        "ruby-lsp"
      ],
      "selector": "source.ruby",
      "initializationOptions": {
        "enabledFeatures": {
          "diagnostics": true
        },
        "experimentalFeaturesEnabled": true
      },
      "lsp_debug": true
    }
  • Using chruby for ruby version management
  • launching sublime with subl from within a given project
  • subl is part of my PATH and not a symlink.
  • ruby version is defined in a .ruby-version file
  • ruby-lsp part of my gemfile
    -ruby-lsp installs without problems with bundle install (from a shell)
  • ruby-lsp command runs in my local environment without problems (from a shell)

Troubleshooting: ruby-lsp

Version

  • LSP: 2.2.0
  • Sublime Text: 4180

Server Test Run

  • exit code: 1
  • output
Ignoring prism-1.2.0 because its extensions are not built. Try: gem pristine prism --version 1.2.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
Ignoring rbs-3.6.1 because its extensions are not built. Try: gem pristine rbs --version 3.6.1
Ignoring rbs-3.4.0 because its extensions are not built. Try: gem pristine rbs --version 3.4.0
/Users/peter.lehwess/.gem/ruby/3.3.5/gems/sorbet-runtime-0.5.11645/lib/types/private/methods/_methods.rb:127:in `<module:Methods>': undefined method `const_source_location' for T:Module (NoMethodError)
	from /Users/peter.lehwess/.gem/ruby/3.3.5/gems/sorbet-runtime-0.5.11645/lib/types/private/methods/_methods.rb:4:in `<top (required)>'
	from /Users/peter.lehwess/.gem/ruby/3.3.5/gems/sorbet-runtime-0.5.11645/lib/sorbet-runtime.rb:25:in `require_relative'
	from /Users/peter.lehwess/.gem/ruby/3.3.5/gems/sorbet-runtime-0.5.11645/lib/sorbet-runtime.rb:25:in `<top (required)>'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/peter.lehwess/.gem/ruby/3.3.5/gems/ruby-lsp-0.21.3/lib/ruby_lsp/setup_bundler.rb:4:in `<top (required)>'
	from /Users/peter.lehwess/.gem/ruby/3.3.5/gems/ruby-lsp-0.21.3/exe/ruby-lsp:72:in `require_relative'
	from /Users/peter.lehwess/.gem/ruby/3.3.5/gems/ruby-lsp-0.21.3/exe/ruby-lsp:72:in `<top (required)>'
	from /Users/peter.lehwess/.gem/ruby/3.3.5/bin/ruby-lsp:25:in `load'
	from /Users/peter.lehwess/.gem/ruby/3.3.5/bin/ruby-lsp:25:in `<main>'

Server Configuration

  • command
[
  "ruby-lsp"
]
  • shell command
ruby-lsp
  • selector
source.ruby
  • priority_selector
source.ruby
  • init_options
{
  "enabledFeatures": {
    "diagnostics": true
  },
  "experimentalFeaturesEnabled": true
}
  • settings
{}
  • env
{}

Active view

  • File name
/Users/peter.lehwess/development/*****/*****/Gemfile
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
  "lsp_active": true,
  "syntax": "Packages/Ruby/Ruby.sublime-syntax"
}
  • base scope
source.ruby

Project / Workspace

  • folders
[
  "/Users/peter.lehwess/development/****/******"
]
  • is project: False

LSP configuration

{
  "clients": {
    "ruby": {
      "command": [
        "solargraph",
        "stdio"
      ],
      "initializationOptions": {
        "diagnostics": true
      },
      "selector": "source.ruby | text.html.ruby"
    },
    "ruby-lsp": {
      "command": [
        "ruby-lsp"
      ],
      "enabled": true,
      "initializationOptions": {
        "enabledFeatures": {
          "diagnostics": true
        },
        "experimentalFeaturesEnabled": true
      },
      "lsp_debug": true,
      "selector": "source.ruby"
    }
  },
  "log_debug": true
}

System PATH

  • /Users/peter.lehwess/.nvm/versions/node/v18.15.0/bin
  • /opt/homebrew/bin
  • /opt/homebrew/sbin
  • /Applications/Sublime Text.app/Contents/SharedSupport/bin
  • /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
  • /Users/peter.lehwess/.gem/ruby/3.3.5/bin
  • /Users/peter.lehwess/.rubies/ruby-3.3.5/lib/ruby/gems/3.3.0/bin
  • /Users/peter.lehwess/.rubies/ruby-3.3.5/bin
  • /opt/homebrew/bin
  • /opt/homebrew/sbin
  • /Applications/Sublime Text.app/Contents/SharedSupport/bin
  • /Users/peter.lehwess/.nvm/versions/node/v18.15.0/bin
  • /Applications/iTerm.app/Contents/Resources/utilities
  • /Users/peter.lehwess/Library/Application Support/JetBrains/Toolbox/scripts
  • /Users/peter.lehwess/Library/Application Support/JetBrains/Toolbox/scripts
@leewaa leewaa added bug Something isn't working help-wanted Extra attention is needed non-vscode labels Nov 9, 2024
@vinistock
Copy link
Member

Thank you for the bug report! I believe the issue is that the chruby environment is not activated inside the process that runs Sublime Text, which is documented here under the important tip.

Essentially, chruby mutates a few environment variables to allow ruby and gem executables to properly find things. That happens in your terminal, but it does not happen inside the process running Sublime Text. The fact that it's trying to use Ruby 2.6 gives it away, because that's the system Ruby - the one available when no environment variables have been mutated.

Ensure that chruby is activating the environment before invoking ruby-lsp in your command configuration. Instead of using simply ruby-lsp, you need to either switch the version and then call the gem executable or use something like chruby-exec. Something along the lines of

chruby $(cat .ruby-version) && ruby-lsp

Please report back if it works or if you encounter any issues. We will also gladly accept improvements to our editors documentation for better Sublime instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help-wanted Extra attention is needed non-vscode
Projects
None yet
Development

No branches or pull requests

2 participants