Install ruby on Ubuntu 20.04 with rbenv

environment

As a prerequisite, a virtual environment created on VMware. Install ruby using rbenv from a fresh state where the OS is installed.

Ruby installation on Ubuntu

The reference article is here. First, install git. For the time being, make sure that git is not installed by default.

$ git

command'git'Cannot be found. You can install it in the following ways:

sudo apt install git

Then install.

$ sudo apt install git

For the time being, leave the log at the time of installation as text. After installation, make the following settings.

$ git config --global user.name [User name]
$ git config --global user.email [mail address]

Since the installation of git is completed, install Ruby from here. First, download rbenv.

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Add the following description to .bashrc (you can write a string to a file with echo'string'>>'filename').

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc

After executing, if you check the contents of .bashrc with an editor, you can see that the echoed content is added to the end of the file. captcher01.png

Read the contents of .bashrc with the source command.

$ source ~/.bashrc

Check the version of Ruby that can be installed

$ rbenv install -l
2.5.8
2.6.6
2.7.1
jruby-9.2.12.0
maglev-1.0.0
mruby-2.1.1
rbx-5.0
truffleruby-20.1.0
truffleruby+graalvm-20.1.0

Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all' to show all local versions.

It seems that only 2.5 to 2.7 within the support range can be installed. Although the version is different from the reference book, I decided to install it with 2.5.8.

$ rbenv install 2.5.8

Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...

WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.


BUILD FAILED (Ubuntu 20.04 using ruby-build 20200727)

Inspect or clean up the working tree at /tmp/ruby-build.20200728011639.10883.ljBQV0
Results logged to /tmp/ruby-build.20200728011639.10883.log

Last 10 log lines:
checking for ruby... false
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/ruby-build.20200728011639.10883.ljBQV0/ruby-2.5.8':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

I got an error. It looks like an error saying that the C compiler is not included, so try installing gcc.

$ sudo apt install gcc

It ended normally. Also here, record the installation log as text for the time being.

Install ruby with rbenv again

$ rbenv install 2.5.8

Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...

WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.


BUILD FAILED (Ubuntu 20.04 using ruby-build 20200727)

Inspect or clean up the working tree at /tmp/ruby-build.20200728013413.16282.OsujhX
Results logged to /tmp/ruby-build.20200728013413.16282.log

Last 10 log lines:
checking for _setjmp as a macro or function... yes
checking for sigsetjmp as a macro or function... no
checking for setjmp type... __builtin_setjmp
checking for prefix of external symbols... NONE
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking if make is GNU make... ./configure: line 27352: make: command not found
no
checking for safe null command for make... configure: error: no candidate for safe null command

I got an error again. This time make is not installed! Error.

$ sudo apt install make

As usual, leave the installation log as text.

This time, install ruby with rbenv.

$ rbenv install 2.5.8
The Ruby openssl extension was not compiled.
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
Try running `apt-get install -y libssl-dev libreadline-dev zlib1g-dev` to fetch missing dependencies.

Another error, apparently due to the lack of "openssl", "readline" and "zlib". For the time being, try to follow the instructions.

$ apt-get install -y libssl-dev libreadline-dev zlib1g-dev

This is completed without any problems. Install again with rbenv.

$ rbenv install 2.5.8
Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...

WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.

Installed ruby-2.5.8 to /home/kei/.rbenv/versions/2.5.8

I was able to install it!

Finally, specify the version with rbenv and complete.

$ rbenv global 2.5.8

Also check the version.

$ ruby -v
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]

Recommended Posts

Install ruby on Ubuntu 20.04 with rbenv
Install Ruby on Ubuntu 20.04
Install Ruby on MSYS2 with pacman
Installing Ruby + Rails on Ubuntu 18.04 (rbenv)
Install Gradle with ubuntu16.04
Install Homebrew on Ubuntu 20.04
Minimal steps to set up a Ruby environment with rbenv on Ubuntu 20.04
Install OpenJDK7 (JAVA) on ubuntu 14.04
Ruby version switching with rbenv
Install Cybozu Office 10 on Ubuntu 20.4
Install Docker on Ubuntu Server 20.04
Install zabbix agent (5.0) on Ubuntu 18.04
Install MAV Proxy on Ubuntu 18.04
Install Java on WSL Ubuntu 18.04
Ruby installation on WSL2 + Ubuntu 20.04
Install Ubuntu Desktop 20.10 on RaspberryPi4
Install Arduino IDE on Ubuntu 20.04
Install raspi-config on Ubuntu 20.04 (LTS)
Install Ruby 2.7 on RHEL 8 (AppStream)
Install Ruby 2.7 on CentOS 7 (SCL)
Install PlantUML on Intellij on Ubuntu
Install Ubuntu Server 20.04 on Btrfs
Note: Install PostgreSQL 9.5 on Ubuntu 18.04
Install Ruby on Sakura's VPS
Install java with Ubuntu 16.04 based Docker
Install AWS IoT Greengrass on Ubuntu
[Ruby on Rails] yarn install --check-files
Install JDK and JRE on Ubuntu 16.10
Install Java with zip on Windows
Install ngrok on ubuntu16.04 using Vagrant
How to install ruby through rbenv
Install Ruby 2.5 on CentOS 7 using SCL
Programming with ruby (on the way)
How to install WildFly on Ubuntu 18.04
Install Ruby 3.0.0 Preview 1 with a combination of Homebrew and rbenv
How to install Adopt OpenJDK on Debian, Ubuntu with apt (-get)
Install Ubuntu Server 20.04 in VirtualBox on Mac and connect with SSH
[Ruby on Rails] View test with RSpec
Headless install of Ubuntu 20.10 on Raspberry Pi
Install OpenJDK (Java) on the latest Ubuntu
I want to install PHP 7.2 on Ubuntu 20.04.
Install Realtek network driver on Ubuntu Note
[Ruby on Rails] Controller test with RSpec
DNS over HTTPS with Cloudflared on Ubuntu
[Ruby] Building a Ruby development environment on Ubuntu
Install Java8 with Yum on Amazon Linux
Use cljstyle with Spacemacs on Ubuntu on WSL2
Build OpenCV with Java Wrapper on Ubuntu 18.04
[Ruby on Rails] Model test with RSpec
Run Ubuntu + ROS with Docker on Mac
When building rails6 environment on Ubuntu, it gets stuck with bundle install
tmux on Ubuntu
Wine settings on Ubuntu 18.04 (install WOLF RPG Editor)
Install NextCloud on CentOS 7 with Alibaba Cloud ECS
Build and install Wireshark Development Release (3.3.1) on Ubuntu
Introducing Rspec with Ruby on Rails x Docker
How to install network drivers on standalone Ubuntu
Publish the app made with ruby on rails
Manage the version of Ruby itself with rbenv
Note Book: OpenCV with CUDA Install On Windows10
How to install NVIDIA driver on Ubuntu 18.04 (Note)