-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Check if solargraph
is already installed and in $PATH
in project dir
#9811
Comments
Hey @odedharth, I think our implementation of Ruby currently expects you to install solargraph manually. I'm not sure what situation we ran into that caused us to make that decision, but here are the docs on it: Let me know if you get it up and running. Just to mention it, @mrnugget has a PR open that switches us over to |
Hey @JosephTLyons, Yes, the issue is that I already have solargraph installed. It used to work in the past and seems to have gotten broken in one of the last versions. |
@odedharth can you paste the language server logs ( On latest Zed stable version it works for me. In the case of screenshot-2024-03-27-09.16.31.mp4 |
@mrnugget sure, that's what I'm seeing there after startup: ![]() And when I require 'date', it still doesn't do anything. |
Can you select |
@mrnugget, it's not showing as an option (even though the gem is installed) |
Huh! Interesting! That means it didn't even start yet. Can you paste the logs from |
It looks like solargraph is installed with a different version than the one you're using in your projects:
Can you even run solargraph manually? What happens if you do this:
|
this is what happens:
it's strange that it was looking for rbenv, since I've switched to chruby. Please see the new log file: |
I've installed Solargraph manually with Ruby 3.2.3, and it fixed it. I'm wondering why was Zed looking for the 3.2.3 ruby version? |
It depends on how you've setup your Ruby versions. What Zed does by default is to load the env of a user in the homedirectory. So if you have rbenv/chruby set to use version X.Y in your home dir, but to Z.X in your project dir, then Zed won't pick that up. We can change it and look up solargraph dynamically. |
solargraph
is already installed and in $PATH
in project dir
This appears to be the biggest blocker for me adopting Zed over Neovim (well, maybe a good integrated test runner also?!). I have posted in the discussion about using StandardRB to format code. I now believe my issues are related to this issue. I use asdf to manage my Rubies and other tools. I have Bundler configured to install Gems into a Anyway, I was going to file an issue about this but I feel it is the issue described here but a little wider. Should I file it separately? |
This fixes #9811 by checking for the `solargraph` binary in the `$PATH` as its setup in the project shell. It also adds support for configuring the path to `solargraph` manually: ```json { "lsp": { "solargraph": { "binary": { "path": "/Users/thorstenball/bin/solargraph", "arguments": ["stdio"] } } } } ```
thanks @rhatherall for the comment. Your description of the setup finally gave me confidence that this is the right solution. I went ahead and opened #10835, which should fix this for you. |
This fixes #9811 by checking for the `solargraph` binary in the `$PATH` as it's setup in the project shell. It also adds support for configuring the path to `solargraph` manually: ```json { "lsp": { "solargraph": { "binary": { "path": "/Users/thorstenball/bin/solargraph", "arguments": ["stdio"] } } } } ``` ## Example Given the following setup: - `ruby@3.3.0` used globally, no `solargraph` installed globally - `ruby@3.2.2` used in a project, `solargraph` installed as binstub in `$project/bin/solargraph`, `.envrc` to configure `direnv` to add `$project/bin` to `$PATH Which looks like this in practice: ```shell # GLOBAL ~ $ ruby --version ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23] ~ $ which solargraph solargraph not found # IN PROJECT ~ $ cd work/projs/rails-proj direnv: loading ~/work/projs/rails-proj/.envrc direnv: export ~PATH ~/work/projs/rails-proj $ ruby --version ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23] ~/work/projs/rails-proj $ which solargraph /Users/thorstenball/work/projs/rails-proj/bin/solargraph ``` The expectation is that Zed, when opening `~/work/projs/rails-proj`, picks up the local `solargraph`. But with **Zed Stable** that doesn't work, as we can see in the logs: ``` 2024-04-22T10:21:37+02:00 [INFO] starting language server. binary path: "solargraph", working directory: "/Users/thorstenball/work/projs/rails-proj", args: ["stdio"] 2024-04-22T10:21:37+02:00 [ERROR] failed to start language server "solargraph": No such file or directory (os error 2) ``` With the change in this PR, it uses `rails/proj/bin/solargraph`: ``` [2024-04-22T10:33:06+02:00 INFO language] found user-installed language server for Ruby. path: "/Users/thorstenball/work/projs/rails-proj/bin/solargraph", arguments: ["stdio"] [2024-04-22T10:33:06+02:00 INFO lsp] starting language server. binary path: "/Users/thorstenball/work/projs/rails-proj/bin/solargraph", working directory: "/Users/thorstenball/work/projs/rails-proj", args: ["stdio"] ``` **NOTE**: depending on whether `mise` (or `rbenv`, `asdf`, `chruby`, ...) or `direnv` come first in the shell-rc file, it picks one or the other, depending on what puts itself first in `$PATH`. ## Release Notes Release Notes: - Added support for finding the Ruby language server `solargraph` in the user's `$PATH` as it is when `cd`ing into a project's directory. ([#9811](#9811)) - Added support for configuring the `path` and `arguments` for `solargraph` language server manually. Example from settings: `{"lsp": {"solargraph": {"binary": {"path":"/Users/thorstenball/bin/solargraph","arguments": ["stdio"]}}}}` ([#9811](#9811))
Check for existing issues
Describe the bug / provide steps to reproduce it
Autocomplete works for certain files like JS for example, but doesn't work at all for Ruby files.
See here: https://www.loom.com/share/5dc993f5cba24413b43b350c0d0a6d19
Environment
Zed: v0.127.5 (Zed)
OS: macOS 14.4.1
Memory: 64 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.No response
The text was updated successfully, but these errors were encountered: