[Ruby] rbenv install 2.7.1 fails with no acceptable C compiler found in $PATH cannot load such file

1 minute read


  • rbenv 1.1.2-30-gc879cb0
  • ruby-build 20200520-12-g69ccbf4
  • Ubuntu 20.04 LTS (Focal Fossa) [Windows Subsystem for Linux 2; WSL2]


Installation of rbenvandruby-build is completed, and rbenv-doctor script is used. 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


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 the full error message is posted, it is truly redundant. , The characteristic part is extracted)

  • configure: error: no acceptable C compiler found in $PATH
  • cannot load such file-openssl (LoadError)
  • cannot load such file-digest/sha2.so (LoadError)

Causes and countermeasures

This was due to a lack of libraries needed to build Ruby. The __ruby-build wiki has a page [https://github.com/rbenv/ruby-build/wiki] which is a page that summarizes the libraries required to build Ruby and how to install them for each OS. With this as a reference, I installed Ruby 2.7.1 by doing rbenv install after installing the missing libraries in my environment (Ubuntu).

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