I had never touched Ruby, so I decided to try it again and built a Ruby environment on my Mac. Ruby is installed as standard on Mac, but the version is old, so if you install the latest version anyway, it is the same as PHP's phpenv I thought that it would be easier to switch between multiple versions of Ruby by inserting rbenv, so I wrote this article.
MacBook Pro 13 - macOS Mojave 10.14.6
In this procedure, it is assumed that Homebrew is installed in advance because the brew command is used.
Manage multiple versions of Ruby on your Mac and switch between them so you can use them. (The version is different for each project)
First, Homebrew update
$ brew update
Then install rbenv
$ brew install rbenv
...
Error: Permission denied @ apply2files - /usr/local/lib/node_modules/cordova/node_modules/extglob/lib/.DS_Store
I got a permission error in my environment, but Ignore it because it's from .DS_Store
Finally check the version of rbenv
$ rbenv --version
rbenv 1.1.2-11-gc46a970
This completes the installation! It's too easy to beat. I only remember that it was more troublesome when I introduced PHP's phpenv. .. ..
You can get help by running the rbenv command with no arguments, but just in case.
$ rbenv
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
install Install a Ruby version using ruby-build
uninstall Uninstall a specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List installed Ruby versions
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/rbenv/rbenv#readme
$ rbenv install --list-all
1.8.5-p52
1.8.5-p113
1.8.5-p114
...
$ rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
ruby-build: using readline from homebrew
Installed ruby-2.7.1 to /Users/XXXXX/.rbenv/versions/2.7.1
$ rbenv versions
* system (set by /Users/XXXXX/.rbenv/version)
2.7.1
* System is Ruby originally installed on Mac
$ rbenv version
system (set by /Users/XXXXX/.rbenv/version)
$ rbenv local 2.7.1
$ruby global 2.7.1
Various commands and the operation of each command are the same as phpenv. So if you have used phpenv, you may be able to use it without any discomfort.
Recommended Posts