AWS(Amazon Linux2)環境にて、Rubyインストール時に嵌った時の解決メモ
環境
Amazon Linux2
amzn2-ami-hvm-2.0.20180810-x86_64-gp2 (ami-08847abae18baa040)
Ruby2.5.1
嵌る前の手順
# ホームディレクトリにて作業用ディレクトリ「workdir」を作成して、移動
mkdir workdir
cd workdir
# rubyのインストールファイルをダウンロード
wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz
# 解凍して、解凍先に移動
tar xvf ruby-2.5.1.tar.gz
cd ruby-2.5.1
はまった点
# Makefileファイルの作成でエラーが発生してしまった!!!
./configure --prefix=/usr/local/ruby
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 `/home/ec2-user/workdir/ruby-2.5.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
- エラーメッセージを読んでみると、Cコンパイラが見つからない模様
調査内容
-
AWS Linuxには、コンパイラ系ツール(make、gcc、autoconf)はインストールされていない為、該当のエラーが発生している模様
システムでソフトウェアのコンパイルを可能にするには、make、gcc、autoconf など、いくつかの開発ツールをインストールする必要があります。
(中略)
ソフトウェアのコンパイルはすべての Amazon EC2 インスタンスで必要なタスクではないため、そのようなツールはデフォルトでインストールされていません。
解決方法
- Cコンパイラをインストールしますが、上記調査内容に示したAWSサイトのドキュメントに記載のとおり、「Development Tools」パッケージグループを、グループインストールすれば良いようです。
yum groupinstall "Development Tools"
- -vオプション付きでコマンド実行して、インストール出来たか確認。
# gccバージョン確認
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-libsanitizer --enable-gnu-indirect-function --enable-libcilkrts --enable-libatomic --enable-libquadmath --enable-libitm --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)
# makeバージョン確認
make -v
GNU Make 3.82
Built for x86_64-koji-linux-gnu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
改めて、Rubyインストールの続行
# configureシェルを実行し、Makefileを作成
./configure --prefix=/usr/local/ruby
# makeコマンドを実行、ソースファイルのコンパイルを行って
make
# インストールの実施
make install
# インストールパスを環境変数PATHに設定します
export PATH=/usr/local/ruby/bin:$PATH
無事にRubyがインストールできか確認します。
ruby-v
- インストールできたようです!
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]