DEV Community

Discussion on: The Evolution of Ruby Version Management

Collapse
 
salex profile image
Steve Alex

I've spent a couple days trying to understand how to use mise with Ruby and RoR. I have to admit I'm lost!

This was on a bare bones new Ubuntu server. I finally got ruby 3.2 installed after many tries at this and that. I could get mise use --global ruby to create a new ruby version. I could get mise use -- ruby -v got print the version. But nowhere can I find on how to use it with Rails.

Can't use it to install the Rails gem or do anything but display the version number!

I know I'm missing a lot but until there is some use documentation, I'll stick with rbenv. I'm in no hurry. old stuff works!

Collapse
 
salanoid profile image
Salajan Silviu

I tried Mise because DHH uses it, and it's nice since you can install multiple languages with it. In omakub, you can find a script on how to use it, but for me, the official documentation was good enough. Mise is still a relatively new version manager, and its documentation can be sparse.

1. Ensure Mise is Activating the Correct Ruby

Run:

mise exec -- ruby -v
Enter fullscreen mode Exit fullscreen mode

This ensures that Ruby is being executed through Mise. If the version doesn’t match what you expect, try:

mise reshim
Enter fullscreen mode Exit fullscreen mode

This regenerates the shims to properly point to the installed binaries.

2. Install Bundler and Rails with Mise's Ruby

Since Mise manages versions but not gems directly, you need to install Bundler and Rails inside the version of Ruby that Mise is using:

mise exec -- gem install bundler
mise exec -- gem install rails
mise reshim # Important after installing gems with binaries
Enter fullscreen mode Exit fullscreen mode

3. Check if Rails is Available

Try running:

mise exec -- rails -v
Enter fullscreen mode Exit fullscreen mode

If that works, then your Rails installation is functioning properly.

4. Global vs Local Environment Setup

Global Installation

If you want Rails available globally, install it in the global Ruby environment:

mise use --global ruby@3.2
mise exec -- gem install rails
mise reshim
Enter fullscreen mode Exit fullscreen mode

Per-Project Setup

If you prefer a per-project setup, use a .tool-versions file in your project directory:

echo "ruby 3.2" > .tool-versions
mise install
mise exec -- gem install rails
mise reshim
Enter fullscreen mode Exit fullscreen mode

5. Ensure Shell is Set Up Correctly

If you’re having trouble, check your shell configuration to ensure Mise is initialized properly. Add this to ~/.bashrc or ~/.zshrc:

eval "$(mise activate)"
Enter fullscreen mode Exit fullscreen mode

Then restart your terminal or run:

source ~/.bashrc # or source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

If these steps still don’t work, I totally get sticking with rbenv if it works for you—Mise is still growing.

Collapse
 
salex profile image
Steve Alex

I finally found a good article on how to use mise with rails. Damn if I can find it!

It came down to putting

eval "$(~/.local/bin/mise activate)"

in my .bashrc file. About the same as you suggested.

Thread Thread
 
salanoid profile image
Salajan Silviu

Nice, good job! 😄 ㊗️