EC2インスタンスにrubyをインストール際のエラーの対象方法
今日は、個人アプリをデプロイしようと思いまして、 EC2インスタンスにまずはrubyをインストールしようと思ったのですが、
早速エラーが出たので忘備録として記録します。
EC2インスタンスにログイン後、
rbenv install 2.5.1
を入れるとエラーが起きました。
こちらがエラー文です。
[ec2-user@ip-172-31-XX-XXX ~]$ 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 (Amazon Linux AMI 2018.03 using ruby-build 20190423-4-gac92ec0) Inspect or clean up the working tree at /tmp/ruby-build.20190608070902.8678 Results logged to /tmp/ruby-build.20190608070902.8678.log Last 10 log lines: tool/config.sub already exists 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.20190608070902.8678/ruby-2.5.1': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
checking for gcc... no
checking for cc... no
checking for cl.exe... no と記述があります。
そこで、 gccをインストールするために、
を実行。
すると、、
[ec2-user@ip-172-31-XX-XXX ~]$ 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 (Amazon Linux AMI 2018.03 using ruby-build 20190423-4-gac92ec0) Inspect or clean up the working tree at /tmp/ruby-build.20190608073429.26235 Results logged to /tmp/ruby-build.20190608073429.26235.log Last 10 log lines: installing rdoc: /home/ec2-user/.rbenv/versions/2.5.1/share/ri/2.5.0/system installing capi-docs: /home/ec2-user/.rbenv/versions/2.5.1/share/doc/ruby The Ruby readline extension was not compiled. ERROR: Ruby install aborted due to missing extensions Try running `yum install -y readline-devel` to fetch missing dependencies. Configure options used: --prefix=/home/ec2-user/.rbenv/versions/2.5.1 LDFLAGS=-L/home/ec2-user/.rbenv/versions/2.5.1/lib CPPFLAGS=-I/home/ec2-user/.rbenv/versions/2.5.1/include
さっきとは違うエラーが出ちゃいました。。
エラー文を読むと、
The Ruby readline extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running yum install -y readline-devel
to fetch missing dependencies.
とあります。
そのため、
sudo yum install readline-develを実行し、
readline-develをインストール。
そして、インストール後に、 再度rbenv install 2.5.1を実行!
すると、、、
[ec2-user@ip-172-31-XX-XXX ~]$ 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... Installed ruby-2.5.1 to /home/ec2-user/.rbenv/versions/2.5.1
見事インストールできました!!