rbenv install 2.7.1 fails with "no acceptable C compiler found in $ PATH" and "cannot load such file"

environment

Premise

Installation of rbenv and ruby-build is completed, and by rbenv-doctor script Verification is OK.

$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /home/dev/.rbenv/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /home/dev/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20200520-12-g69ccbf4)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/home/dev/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

problem

After the installation of rbenv + ruby-build was completed, Ruby2.7.1 was installed by rbenv install -v 2.7.1, but it failed due to the following reasons (because it is redundant to post the full error). , Excerpts of characteristic parts)

Causes and countermeasures

__ The cause was a lack of libraries needed to build Ruby. The __ruby-build wiki has a page that summarizes the libraries required to build Ruby and how to install them for each OS. With this as a reference, after installing the missing libraries in my environment (Ubuntu), I was able to install Ruby 2.7.1 by doing rbenv install.

sudo apt update 
sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev

Recommended Posts

rbenv install 2.7.1 fails with "no acceptable C compiler found in $ PATH" and "cannot load such file"
When you get LoadError (cannot load such file --ruby_file) when you require in Ruby
When dealing with whenever in Docker No such file or directory --crontab
[Error] `cannot load such file --mime/types/data (LoadError)`
[Windows] gem install sqlite3 cannot be done ~ Cannot create temporary file in C: \ version ~