LoginSignup
9
11

More than 5 years have passed since last update.

Ubuntu16.04LTS に Ruby2.2.3をインストール

Last updated at Posted at 2017-02-13

環境

OS: Ubuntu16.04LTS (Xenial Xerus)
Ruby: 2.2.3をインストールしたい

手順

(参考URL)Ubuntu16.04(Xenial)でRoRをはじめる

1.rbenv等パッケージインストール

sudo apt-get install rbenv
sudo apt-get install ruby-build
sudo apt-get install ruby-dev
sudo apt-get update

2.rbenvの初期化

echo 'eval $(rbenv init -)' >> ~/.profile

リロードする。

. /.profile
hash -r

PATHの確認をする

echo "#{PATH}"

3.インストール

以下コマンドでインストール可能なrubyのバージョンを確認します。

rbenv install --list

今回は、無印の最新版である2.2.3をインストールします。

rbenv install 2.2.3

実行結果は以下の通り、、、エラーが発生しました。。。

Downloading ruby-2.2.3.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/df795f2f99860745a416092a4004b016ccf77e8b82dec956b120f18bdc71edce
Installing ruby-2.2.3...

BUILD FAILED (Ubuntu 16.04 using ruby-build 20151028)

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

Last 10 log lines:
compiling ../.././ext/psych/yaml/dumper.c
compiling ../.././ext/psych/yaml/loader.c
installing default psych libraries
linking shared-object psych.so
make[2]: ディレクトリ '/tmp/ruby-build.20170213171745.9277/ruby-2.2.3/ext/psych' から出ます
linking shared-object ripper.so
make[2]: ディレクトリ '/tmp/ruby-build.20170213171745.9277/ruby-2.2.3/ext/ripper' から出ます
make[1]: ディレクトリ '/tmp/ruby-build.20170213171745.9277/ruby-2.2.3' から出ます
uncommon.mk:189: ターゲット 'build-ext' のレシピで失敗しました
make: *** [build-ext] エラー 2

4.エラーの対処

上記メッセージの8行目に

Results logged to /tmp/ruby-build.20170213171745.9277.log

とあり、こちらのエラーを確認したところ、
1)libffi-dev が無いことが原因
2)open-ssl関連が悪さをしている
と2箇所怪しいところがありました。

ますは1)を解消するために、

sudo apt-get install libffi-dev

を実行するも、エラー内容は変わりません。

2)に対して、rubyインストール時のopen-ssl関連のエラーを探したところ、GitHubで以下のページを発見しました。
[Cannot install Ruby 2.2.3 in ubuntu 14.04](https://github.com/rbenv/ruby-build/issues/834)

上記ページを参照し、以下のコマンドを実行します。

curl -fsSL https://gist.github.com/mislav/055441129184a1512bb5.txt | rbenv install --patch 2.2.3

無事インストールが完了しました^^

9
11
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
9
11