Trying Mise: Simplifying Ruby Version Management and other benefits
I've been reacquainted with Ruby lately. I had it lying around on my machine but couldn't quite remember how I managed versions and switched between them. It turned out I was using Homebrew, ruby-install, and chruby. I updated the packages to their latest versions, then installed the latest version of Ruby:
brew upgrade ruby-install chruby
ruby-install 3.4
This installed Ruby 3.4.6.
If configured, chruby will automatically switch to the current version of Ruby when you cd into a directory. It looks for a .ruby-version file.
A newer alternative
I recently came across Mise, a "polyglot tool version manager". It aims to replace many version managers like nvm, ruby-install, and so on. I installed Mise (after editing my .zshrc file) and ran mise use -g ruby@3.4. It worked fine. Mise also manages environment variables and includes a task runner. I also installed Node.
Mise looks promising. For me, the main benefit is improved shell start-up time. My machine is a 2015 MacBook, so it's a bit slow when loading multiple version managers. It took about 1 or 2 seconds to start a shell with nvm and chruby in the mix; with Mise the shell starts immediately.
I'll give it a go for a while.
Update
After trying to install ruby gems, I was getting mixed success.
The Problem: I was running Ruby 3.4.7 (via mise), but gem env showed gems were being installed to my old Ruby 3.2.0 directory. The gems existed, but their compiled C extensions were built for 3.2.0 and couldn't work with 3.4.7.
The Cause: Old GEM_HOME or GEM_PATH environment variables in my shell config, pointing to the 3.2.0 installation and overriding mise's proper paths.
The Fix:
unset GEM_HOME
unset GEM_PATH
# Reload shell
source ~/.zshrc
# Reinstall gems