LoginSignup
13
10

More than 3 years have passed since last update.

【Tips】rbenvでRuby2.4.0未満をインストールしようとしたときに発生するエラーへの対処

Last updated at Posted at 2018-10-17

問題:Rubyインストールにおけるエラー

入力

rbenv install 2.2.5

出力

Downloading ruby-2.2.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.bz2
Installing ruby-2.2.5...

WARNING: ruby-2.2.5 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.


BUILD FAILED (Ubuntu 18.04 using ruby-build 20180618-5-gad8f3a4)

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

Last 10 log lines:
../../internal.h:84:30: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
linking shared-object objspace.so
make[2]: ディレクトリ '/tmp/ruby-build.20181018001254.16775/ruby-2.2.5/ext/objspace' から出ます
linking shared-object date_core.so
make[2]: ディレクトリ '/tmp/ruby-build.20181018001254.16775/ruby-2.2.5/ext/date' から出ます
linking shared-object nkf.so
make[2]: ディレクトリ '/tmp/ruby-build.20181018001254.16775/ruby-2.2.5/ext/nkf' から出ます
make[1]: ディレクトリ '/tmp/ruby-build.20181018001254.16775/ruby-2.2.5' から出ます
uncommon.mk:189: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

環境

  • Lubuntu 18.04 LTS
  • anyenv
    • rbenv 1.1.1-37-g1c772d5

原因:OpenSSLの対応バージョン

Rubyの2.3台まではOpenSSLの1.1に未対応。

解決方法:OpenSSLのダウングレード

sudo apt install libssl1.0-dev
rbenv install 2.2.5

補足

1. その他の原因

openssl以外でRubyのビルドに必要なものがインストールされていない場合も上記と類似したエラーメッセージが表示される。
必要インストールについてはこちらを参照。

2. 事後処理

OpenSSL1.0をインストールすることでOpenSSLがダウングレードしてしまう。
Rubyのインストールが無事終了したら以下を実行。

sudo apt install libssl-dev

3. Pythonの場合

PythonにおいてもPython3系の3.5.3未満で同様の原因でエラーが発生する。
くわしくはこちらの記事を参照。

参考文献

13
10
2

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
13
10