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.
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.
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.
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
A new era of Ruby begins. Let's open the door!
e? "We are Windows"?
Recommended Posts