Install Ruby 3.0.0-preview1 on macOS (also without Homebrew ruby-build)

Introduction

Ruby 3.0.0 Preview 1 has been released. https://www.ruby-lang.org/en/news/2020/09/25/ruby-3-0-0-preview1-released/

You can try the type system (Is it okay to call it?), Ractor that supports concurrent programming, and super-features.

On macOS, there are many people who install Ruby with Homebrew with two packages, rbenv and ruby-build. The readers of this article have that in mind.

Installation (1)

This time, 3.0.0 Preview 1 was released and ruby-build was updated with haste [^ sok], so

[^ sok]: Time lag about 1 day?

brew update
brew upgrade ruby-build
rbenv install 3.0.0-preview1

If so, OK.

Installation part (2)

However, Homebrew's ruby-build is not always updated as soon as the corresponding Ruby is released. This time it was a very nice timing, but in the case of 3.0.0-dev, it was hard to enter even if it was released, and in the end it entered at the same time as 3.0.0-preview1.

In such a case, Slack's ruby-jp told me that there is a way to avoid using Homebrew's ruby-build package.

I've tried it, so I'll write how to do it.

First of all, at present, rbenv and ruby-build are included in Homebrew, so uninstall ruby-build. But simply

brew uninstall ruby-build

When you do

Error: Refusing to uninstall /usr/local/Cellar/ruby-build/20200926
because it is required by rbenv, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies ruby-build

I got an error and could not execute. (The reason why the guy who tried to erase it is the latest as "20200926" is because he did this after brew upgrade)

So, as stated in the message above

brew uninstall --ignore-dependencies ruby-build

I uninstalled it.

Then clone ruby-build from the GitHub repository. When ruby-build is combined with rbenv (it seems that it can be used alone), it must be placed in the plugin storage area so that it works as a plugin for rbenv.

Typically, it's in your home directory called .rbenv / plugins (it's not there if you put ruby-build in Homebrew). In other words, it's ~ / .rbenv / plugins.

However, there may be cases that are not typical, so I want to know the location reliably.

rbenv root

Will display the parent directory of the plugins directory, so use this in the following steps.

First, the plugins directory doesn't always exist, so

mkdir -p "$(rbenv root)"/plugins

To create a directory. It doesn't matter if it already exists.

And

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Then, the latest ruby-build will be cloned to the appropriate place.

In this state

rbenv install 3.0.0-preview1

Then 3.0.0 Preview1 will be installed! The explanation was long, but what you have to do is simple. I just copied and pasted in four places.

When new Ruby is released in the future

git -C "$(rbenv root)"/plugins/ruby-build pull

You can install it by updating ruby-build to the latest version.

This is properly described in the ruby-build README.

Summary for copy

In an environment where rbenv and ruby-build are installed with Homebrew, the entire procedure from uninstalling the Homebrew version of ruby-build to installing Ruby 3.0.0-preview1 is summarized here for easy copying. I did.

Uninstall the Homebrew version of ruby-build:

brew uninstall --ignore-dependencies ruby-build

Clone ruby-build from GitHub:

mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Install Ruby 3.0.0-preview:

rbenv install 3.0.0-preview1

Updated cloned ruby-build:

git -C "$(rbenv root)"/plugins/ruby-build pull

at the end

A new era of Ruby begins. Let's open the door!

e? "We are Windows"?

Recommended Posts

Install Ruby 3.0.0-preview1 on macOS (also without Homebrew ruby-build)
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Java 14 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Java 8 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install OpenJDK on macOS
Install Ruby on Ubuntu 20.04
Install Homebrew on Ubuntu 20.04
Install Java 8 (OpenJDK: Amazon Corretto) on macOS with Homebrew
Install Java 8 (OpenJDK: Zulu Community) on macOS with Homebrew
Install Rails on macOS Catalina
Install Ruby 2.7 on RHEL 8 (AppStream)
Install Ruby 2.7 on CentOS 7 (SCL)
Install Ruby on Sakura's VPS
From 0 to Ruby on Rails environment construction [macOS] (From Homebrew installation to Rails installation)
Install Ruby 3.0.0 Preview 1 with a combination of Homebrew and rbenv
[Java development environment construction] Install OpenJDK 11 (Java 11) on macOS with Homebrew.
Install Ruby on MSYS2 with pacman
[Ruby on Rails] yarn install --check-files
Install Ruby 2.5 on CentOS 7 using SCL
Install ruby on Ubuntu 20.04 with rbenv
Install imagick on macOS Catalina + php 7.4 Note
Install java and android-sdk on Mac using homebrew
Install Ruby / Rails on Mac M1 Big Sur 2021-01
[Ruby on Rails] How to install Bootstrap in Rails
Introducing Eclipse IoT-Part2: Install Eclipse Neon.2 on macOS Sierra