Ubuntu 18.04 に rbenv で Ruby 2.5.1 を入れる時のエラー解決策




Ubuntu 18.04 に rbenv で Ruby 2.5.1 を入れる時のエラー解決策

ruby 2.4未満のものは原因はこちらです。

Ruby < 2.4 is not compatible with openssl 1.1. You need to install libssl1.0-dev.

Can't build on Ubuntu 18.04 (bionic64) · Issue #1199 · rbenv/ruby-build · GitHub

 openssl が問題みたいなんでググったらたくさん出てきます。

Ubuntu 18.04上においてruby-buildでruby 2.3.*をインストールする - 有馬総一郎のブログ



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

BUILD FAILED (Ubuntu 18.04 using ruby-build 20180618-7-gb6428c7)

Inspect or clean up the working tree at /tmp/ruby-build.20180725174713.5661
Results logged to /tmp/ruby-build.20180725174713.5661.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.20180725174713.5661/ruby-2.5.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details



$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec $SHELL

$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
$ exec $SHELL

$ rbenv install 2.5.1
$ rbenv global 2.5.1
$ ruby -v
#=> ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]