How to install ruby through rbenv

As a reminder, I was very worried about installing ruby through rbenv.

What is rbenv in the first place?

Tools for switching and managing ruby versions

Next, I will post the installation procedure (Mac).

Installation procedure

Rough flow

  1. Install Homebrew
  2. Install rbenv via Homebrew
  3. Install ruby via rbenv

1. Install Homebrew

Open the terminal It is around the installation of Homebrew

/bin/bash -c "$(curl -fsSL"

Paste and run This will install Homebrew.

2. Install rbenv via Homebrew

Once Homebrew is installed, then

$brew install rbenv

Enter the command. Enter rbenv -v to check the version of rbenv

3. Install ruby via rbenv

Next, I will install ruby, but to check if there is a desired version

$ rbenv install -l


It will be displayed. If the desired version is not in this, it may not be displayed if the version of rbenv is old. Type $ brew upgrade rbenv ruby-build to update.

If you have the desired Ruby, enter the following to install Ruby.

$ rbenv install (version of target ruby)

How to verify Ruby installation through rbenv

$rbenv version

(Target version) (set by /Users/(username)/.rbenv/version)

You can check the version by typing.

Where I stumbled

Has the Ruby version changed?

Although it is good to install ruby through rbenv

$ruby -v

(Numbers not the desired version)

It was displayed that it was different from the one shown in $ rbenv version.

As a cause

I found out after a lot of research It is a phenomenon caused by the fact that the referenced Ruby has not changed. Originally, Mac already has Ruby, and it refers to the existing Ruby. So, make sure to pass the path to refer to Ruby installed by rbenv.

As a solution

You just have to go through the path, but what do you do? Just write in ~ / .bash_profile to refer to Ruby installed by rbenv

Since there is .bash_profile in the home directory, go to the home directory and go to the home directory Open .bash_profile with vi and write the following

export PATH="~/.rbenv/shims:/usr/local/bin:$PATH"
eval "$(rbenv init -)"

After writing with vi,

source ~/.bash_profile

Enter and restart to change the Ruby version and you're done.


Manage ruby version with rbenv What to do when the Ruby version does not switch! What is the difference between .bash_profile and .bashrc

Recommended Posts

How to install ruby through rbenv
How to install Bootstrap in Ruby
How to use rbenv
How to install Docker
How to install docker-machine
How to install MySQL
How to install ngrok
[Ruby on Rails] How to install Bootstrap in Rails
How to use Ruby return
[Rails] How to install devise
[Ruby] How to comment out
How to install Boots Faces
Rbenv command to use Ruby
Ruby: How to use cookies
[Ruby] How to write blocks
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
How to install JDK8-10 (Mac)
How to install Ruby on an EC2 instance on AWS
[Ruby] How to use rbenv (version `x.x.x'is not installed)
[Rails] How to install Font Awesome
How to iterate infinitely in Ruby
How to install ImageMagick on Windows 10
[How to install Spring Data Jpa]
How to use Ruby on Rails
Super rough! How to install Dagger2
[Ruby] How to use any? Method
How to install MariaDB 10.4 on CentOS 8
[Rails] How to install ImageMagick (RMajick)
[Rails] How to install Font Awesome
How to install WildFly on Ubuntu 18.04
Install ruby on Ubuntu 20.04 with rbenv
How to use Ruby inject method
How to deal with different versions of rbenv and Ruby
How to execute Ruby irb (interactive ruby)
How to install Swiper in Rails
How to get date data in Ruby
[Ruby on Rails] How to use CarrierWave
How to install Eclipse (Photon) on Mac
How to install production Metabase on Ubuntu
Ruby length, size, count How to use
How to install beta php8.0 on CentOS8
[Ruby] How to use slice for beginners
How to install the legacy version [Java]
[Ruby on Rails] How to use redirect_to
[Easy] How to upgrade Ruby and bundler
[Ruby on Rails] How to use kaminari
How to install kafkacat on Amazon Linux2
Ruby: CSV :: How to use Table Note
Introduction to Ruby 2
How to deploy
How to build an environment for any version of Ruby using rbenv
How to find the cause of the Ruby error
[Ruby] How to convert from lowercase to uppercase and from uppercase to lowercase
[Ruby] How to convert CSV file to Yaml (Yml)
[Ruby on Rails] How to display error messages
How to add / remove Ruby on Rails columns
How to make rbenv recognize OpenSSL on WSL
How to install network drivers on standalone Ubuntu
[Ruby] How to use gsub method and sub method
How to install Titan2D (v4.2.0) in virtual environment