LoginSignup
8
2

More than 5 years have passed since last update.

Amazon Linux上でRails新規プロジェクトを作成すると、bundle installで落ちる

Posted at

はじめに

結論からいえば、g++のバージョンのバージョンが古い(v4.8.5)とbundle install時にtherubyracerのコンパイルに失敗するため、bundle installが完了せずRailsサーバーが起動できません。

再現環境

  • Amazon Linux AMI release 2018.03
  • rbenv 1.1.1-40
  • Ruby 2.6.2p47
  • Rails 5.2.2.1
  • g++ version 4.8.5

現象

Railsプロジェクトを新規作成する際、bundle installをしようとすると下記のエラーが発生し完了しませんでした。
therubyracerでC++ソースのコンパイル時にエラーが発生しているようです。


current directory: /home/ec2-user/newprj/vendor/bundle/ruby/2.6.0/gems/therubyracer-0.12.3/ext/v8
/home/ec2-user/.rbenv/versions/2.6.2/bin/ruby -r ./siteconf20180518-15624-zeugq2.rb extconf.rb
checking for -lpthread... yes
creating Makefile

current directory: /home/ec2-user/newprj/vendor/bundle/ruby/2.6.0/gems/therubyracer-0.12.3/ext/v8
make "DESTDIR=" clean

current directory: /home/ec2-user/newprj/vendor/bundle/ruby/2.6.0/gems/therubyracer-0.12.3/ext/v8
make "DESTDIR="
compiling accessor.cc
g++: error: unrecognized command line option ‘-Wmisleading-indentation’
g++: error: unrecognized command line option ‘-Wimplicit-fallthrough=0’
g++: error: unrecognized command line option ‘-Wduplicated-cond’
g++: error: unrecognized command line option ‘-Wrestrict’
make: *** [accessor.o] Error 1

make failed, exit code 2

原因と対処法

g++のバージョン7より古い場合はtherubyracerのコンパイルが出来ません。
単純にバージョン7以降のg++をインストールすることで解決します。

$ g++ -v
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
$ sudo yum remove gcc48-c++.x86_64
$ sudo yum install gcc72-c++.x86_64
$ g++ -v
gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)
8
2
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
8
2