Check if `solargraph` is already installed and in `$PATH` in project dir
Check for existing issues
- [X] Completed
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
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:
https://zed.dev/docs/ruby
Let me know if you get it up and running.
Just to mention it, @mrnugget has a PR open that switches us over to ruby-lsp:
- https://github.com/zed-industries/zed/pull/8613
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 (debug: open language server logs) right after it starts up? The only recent change I can think of is this https://github.com/zed-industries/zed/pull/9170 which should provide more completions.
On latest Zed stable version it works for me. In the case of DateTime I had to first require 'date':
https://github.com/zed-industries/zed/assets/1185253/7ad08cd7-445d-4498-9fac-388645d62e64
@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 solargraph where it says copilot in your screenshot?
@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 ~/Library/Logs/Zed/Zed.log right after you open a Ruby file?
It looks like solargraph is installed with a different version than the one you're using in your projects:
2024-03-13T17:04:02+02:00 [ERROR] server stderr: Some("rbenv: version `3.1.3' is not installed (set by /Users/odedharth/Documents/Apps/Rails/MDAcne/.ruby-version)\n")
...
2024-03-13T17:04:08+02:00 [ERROR] server stderr: Some("rbenv: version `2.6.10' is not installed (set by /Users/odedharth/Documents/Apps/Rails/MDHair/.ruby-version)\n")
Can you even run solargraph manually? What happens if you do this:
env -i HOME="$HOME" $SHELL -i -l -c 'cd /Users/odedharth/Documents/Apps/Rails/MDHair && solargraph'
@mrnugget
this is what happens:
➜ MDHair git:(master) env -i HOME="$HOME" $SHELL -i -l -c 'cd /Users/odedharth/Documents/Apps/Rails/MDHair && solargraph'
zsh:1: command not found: solargraph
it's strange that it was looking for rbenv, since I've switched to chruby. I've deleted rbenv, but it still doesn't work. It seems that it's looking for a gem in ruby 3.2.3 when the project is using ruby 2.6.10
Please see the new log file: Zed.log
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.
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 .bundle directory within each project, and I typically install binstubs for frequently used tools like StandardRB/RuboCop. I have configured my environment path to allow safely referencing binstubs without the bin/ prefix. I have used this setup with Vim and NeoVim for years without issues. Zed does not appear to use Gems local to the project (from the bundle). If I install the Gems globally with gem install, the tools like solargraph, standardrb, etc. start working but they have to be the exact version defined in my project's Gemfile.lock otherwise it will fail with an error. Now, I can get it working for a single project this way but it's completely impractical if you have more than one Ruby project (which I as most will).
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?
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 https://github.com/zed-industries/zed/pull/10835, which should fix this for you.