How to use Ruby with Zed and Mise without shims

Tags:
  • Zed
  • Ruby
  • Mise

Published


TLDR

Terminal window
mise x -- zed .

Director's cut

I'm joining the Better Stack team soon and to get ready I'm working my way through the Ruby on Rails Tutorial.

After a few chapters, I figured I should probably configure the Ruby language server to see how that works. The instructions for that are on Zed's website.

I use Mise to manage language runtimes and dev tools in general. I was pleasantly surprised that the Rails tutorial also suggests using Mise.

I don't know if it's because of Homebrew, but I have a global version of Ruby 2.6 installed on my Mac. The LSP wasn't starting properly and it threw the following error:

Language server ruby-lsp:

from extension "Ruby" version 0.12.0: Failed to install gem 'ruby-lsp': Gem command failed (status: 1)

Error: ERROR: Error installing ruby-lsp:

The last version of rbs (>= 3, < 5) to support your Ruby & RubyGems was 3.1.3. Try installing it with gem install rbs -v 3.1.3 and then running the current command again rbs requires Ruby version >= 3.1. The current ruby version is 2.6.10.210.

-- stderr--

Zed is not detecting the Ruby version installed through Mise. I don't like using shims. I think they defeat the purpose of Mise. I like being able to cd into a directory and get all the tools with the correct version.

To make all tools available on the PATH that Zed uses, I figured the best way is to use mise exec/mise x.

Terminal window
mise x -- zed .

When opening the editor like that, all tools are correctly pointing to the correct version. Would it be nice not having to do this? Sure, but I can live with that.