LoginSignup
6
3

More than 5 years have passed since last update.

Ubuntu18.04にrbenvを使ってRuby2.3インストールしたらコケた話

Posted at

はじめに

Ubuntu18.04にrbenv入れてRuby2.3をインストールしようとしたらコケた話です.
今回は,1時間奮闘の末,解決した方法を載せたいと思います.

もうDockerでいいんじゃない?

エラー

Ruby2.3のインストール時,以下のようなエラーが出ました

~ $ rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...

BUILD FAILED (Ubuntu 18.04 using ruby-build 20181207-4-ge0071f5)

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

Last 10 log lines:
installing rdoc:              /userpath/.anyenv/envs/rbenv/versions/2.3.1/share/ri/2.3.0/system
installing capi-docs:         /userpath/.anyenv/envs/rbenv/versions/2.3.1/share/doc/ruby
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libssl-dev` to fetch missing dependencies.

Configure options used:
  --prefix=/userpath/.anyenv/envs/rbenv/versions/2.3.1
  LDFLAGS=-L/userpath/.anyenv/envs/rbenv/versions/2.3.1/lib
  CPPFLAGS=-I/userpath/.anyenv/envs/rbenv/versions/2.3.1/include

原因

どうやら,Ruby2.4未満のバージョンはoppenssl 1.1と互換性が無いっぽいです.

Ruby < 2.4 is not compatible with openssl 1.1.
You need to install libssl1.0-dev.
https://github.com/rbenv/ruby-build/issues/1199

シェルでopensslのバージョン確認すると

~ $ openssl version
OpenSSL 1.1.0g  2 Nov 2017

1.1になっていますね・・・

解決策

以下のコマンドを打って互換性をもたせましょう! (もうこれだけっ!)

$ sudo apt install libssl1.0-dev

その後,もう一度Ruby2.3をインストールしてみると

~ $ rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...
Installed ruby-2.3.1 to /userpath/.anyenv/envs/rbenv/versions/2.3.1

おわりに

バージョンで上手くいかなくて,それでもめげずに頑張って解決したときの達成感といったら( ´ー`)フゥー...

参考サイト

Ubuntu 18.04上においてruby-buildでruby 2.3.*をインストールする
https://arimasou16.com/blog/2018/04/30/00255/

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3