Use a Ruby version management tool. This class of tool allows you to install and switch between multiple versions of Ruby without needing administrator permissions and without overwriting the operating system installed version:

  • rbenv
  • Ruby Version Manager (RVM)
  • Unleash Ruby (URU)
  • chruby

Example: rbenv

Install rbenv using either of the commands below…

# with curl
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash

# alternatively, with wget
wget -q https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer -O- | bash

…then install the latest Ruby:

rbenv install 2.7.0-preview3
Answer from Graham Miln on Stack Exchange
🌐
Programming Zen
programmingzen.com › home › installing rbenv on zsh (on macos)
Installing rbenv on Zsh (on MacOS) | Programming Zen
November 12, 2020 - In this quick article, I show you how to install rbenv on Zsh on MacOS. The process is fairly straightfoward once you know all the steps.
Discussions

How to install ruby on Mac using rbenv? - Stack Overflow
My problem is ruby -v is not showing the ruby version that I installed (3.0.0). I installed ruby using following commands using homebrew /bin/bash -c "$(curl -fsSL https://raw.githubuserconten... More on stackoverflow.com
🌐 stackoverflow.com
macos - How do I install Ruby without using RVM on OS X? - Stack Overflow
Note that you may want to follow ... eval "$(rbenv init -)" to your profile. ... brew install ruby is all I ever want for my simple Ruby needs - I just use Ruby 2 for nanoc and the odd sysadmin script. I can easily update if necessary, and can aslo just dump all of Homebrew and its installs in one go if I ever need to. I used rvm for a couple of years, but it was way too much overkill and a little too problematic an install on new machines for my ... More on stackoverflow.com
🌐 stackoverflow.com
trouble installing on macos
Make sure your rbenv paths are listed first in your path. More on reddit.com
🌐 r/ruby
13
4
January 4, 2024
Problems installing ruby and rails on Mac with apple silicon
So pretty normal installation process with rbenv? More on reddit.com
🌐 r/rubyonrails
11
12
September 4, 2024
🌐
GitHub
github.com › rbenv › rbenv
GitHub - rbenv/rbenv: Manage your app's Ruby environment · GitHub
This helper is part of the recommended installation instructions, but optional, as an experienced user can set up the following tasks manually. The rbenv init command has two modes of operation: rbenv init: made for humans, this command edits your shell initialization files on disk to add rbenv to shell startup. (Prior to rbenv 1.3.0, this mode only printed user instructions to the terminal, but did nothing else.) rbenv init -: made for machines, this command outputs a shell script suitable to be eval'd by the user's shell.
Starred by 16.7K users
Forked by 1.4K users
Languages   Shell 97.8% | Ruby 1.6%
🌐
GitHub
gist.github.com › stonehippo › cc0f3098516fb52390f1
Installing a new Ruby with rbenv on Mac OS · GitHub
If you're doing stuff with Ruby on a Mac, e.g. installling Jekyll or something, by default you'll end up having to use the sudo command to do stuff, since the permission to modify the default config is not available to your user account. This sucks and should be avoided. Here's how to fix that. To make this better, we are going install a new, custom Ruby. This used to be a big, scary thing, but thanks to the awesome tools Homebrew and rbenv, it's a snap.*
🌐
DEV Community
dev.to › sarahcssiqueira › managing-ruby-versions-on-macos-apple-silicon-with-rbenv-1mon
Managing Ruby versions on macOS Apple Silicon with rbenv - DEV Community
September 14, 2024 - If it does, you're ready to start managing Ruby versions with rbenv. ... This will display a long list of Ruby versions. Choose the one you need (e.g., 3.3.3) and install it: ... This command downloads, compiles, and installs the specified Ruby version on your system. To set this newly installed Ruby version as the global default, run: ... And that's it! You have successfully updated Ruby on your macOS system using rbenv.
Find elsewhere
🌐
Medium
medium.com › @lslozano › installing-ruby-version-manager-on-my-macbook-887dcfe45e99
How to install Ruby Version Manager on Macbook | by Luis Lozano | Medium
October 17, 2022 - Checking for `rbenv' in PATH: /usr/local/bin/rbenv Checking for rbenv shims in PATH: OK Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20170523) Counting installed Ruby versions: none There aren't any Ruby versions installed under `~/.rbenv/versions'. You can install Ruby versions like so: rbenv install 2.2.4 Checking RubyGems settings: OK Auditing installed plugins: OK · If you get that output, you are all set and done! Congratulations, you just installed Ruby Version Manager on your Macbook!
🌐
DEV Community
dev.to › eclecticcoding › set-up-rbenv-revisited-4ngo
Set Up Rbenv Revisited - DEV Community
March 4, 2021 - There is thankfully an easier install script. This script installs or updates rbenv on your system. If Homebrew is detected, installation will proceed using brew install/upgrade. Otherwise, rbenv is installed under ~/.rbenv. Additionally, ruby-build is also installed if rbenv install is not already available.
🌐
Homebrew
formulae.brew.sh › formula › rbenv
rbenv — Homebrew Formulae
brew install rbenv · Ruby version manager · https://rbenv.org · License: MIT · Development: Pull requests · Formula JSON API: /api/formula/rbenv.json · Formula code: rbenv.rb on GitHub · Bottle (binary package) installation support provided.
🌐
Reddit
reddit.com › r/ruby › trouble installing on macos
trouble installing on macos : r/ruby
January 4, 2024 - Make sure your rbenv paths are listed first in your path.
🌐
Dollardhingra
dollardhingra.com › blog › install-ruby-old-versions-macm1
How to install older Ruby versions(2.x) on Mac M1 without using arch x86_64 - Dollar Dhingra’s Blog
January 20, 2022 - RUBY_CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.2 · This should work fine! After this, install other dependencies normally using brew. For eg: postgresql I installed postgresql@10 which was required for the project. ... If you need to have postgresql@10 first in your PATH, run: echo 'export PATH="/opt/homebrew...
🌐
Nurelm
nurelm.com › quickly-setup-your-ruby-environment-with-rbenv
Quickly Setup Your Ruby Environment With rbenv
Innovate with NuRelm. Learn how we partner with businesses and researchers alike to produce web applications, eCommerce and mobile solutions.
🌐
EngineYard
engineyard.com › engine yard blog › ruby on rails › how to install ruby on a mac with chruby, rbenv, or rvm
How to Install Ruby on a Mac with chruby, rbenv, or RVM
March 18, 2022 - It selects a Ruby version for you automatically by looking at ... RVM was the first to be released among the projects mentioned on this post. It has even more features than ... RVM is not available through Homebrew. You can install it with
🌐
DEV Community
dev.to › yasuhiron777 › install-2x-3x-version-of-ruby-via-rbenv-on-m1-mac-3okn
Install 2.x, 3.x version of Ruby via rbenv on M1 Mac - DEV Community
July 6, 2022 - I bought new M1 Mac and struggled to install Ruby. Here’s what I did to solve the issue. This...
🌐
Zerosharp
blog.zerosharp.com › installing-ruby-with-homebrew-and-rbenv-on-mac-os-x-mountain-lion
Installing Ruby with Homebrew and rbenv on Mac OS X Mountain Lion - ZeroSharp
Warning: You have a non-Homebrew 'pkg-config' in your PATH: /usr/bin/pkg-config => /Library/Frameworks/Mono.framework/Versions/2.10.9/bin/pkg-config This was most likely created by the Mono installer. `./configure` may have problems finding brew-installed packages using this other pkg-config. ... Rbenv handles the installation of multiple Ruby environments.
🌐
Reddit
reddit.com › r/rubyonrails › problems installing ruby and rails on mac with apple silicon
r/rubyonrails on Reddit: Problems installing ruby and rails on Mac with apple silicon
September 4, 2024 -

I had trouble with installing ruby and rails on my Mac with M2 and it took me hours to figure out what is wrong. If anybody is having problems try to do it like this:

  1. install homebrew

  2. brew install rbenv ruby-build

  3. rbenv init

  4. add 'eval "$(rbenv init -)"' to ~/.zshrc

  5. source ~/.zshrc or reopen the terminal

  6. rbenv install 3.3.5

  7. rbenv global 3.3.5

  8. reopen the terminal and check it with ruby -v

  9. gem install rails

  10. check rails -v

Hope that this helps.

🌐
Ruby
ruby-lang.org › en › documentation › installation
Installing Ruby | Ruby
mise-en-place allows you to switch between multiple Rubies without requiring additional tools. It manages installations automatically and includes a gem backend to manage versions of CLIs written in Ruby. It supports UNIX-like and Windows operating systems. rbenv allows you to manage multiple installations of Ruby. While it can’t install Ruby by default, its ruby-build plugin can. Both tools are available for macOS, Linux, or other UNIX-like operating systems.