Amazon Linuxでrmagickがインストール・アップデートできなくなった

こんにちは。
定期メンテナンスでRedmineのパッケージも更新を行ったのですが、
bundle installを実行したところ、なぜかrmagickでコケてしまうようになりました…

bundle installを実行すると、以下のログのようにrmagickのインストールでエラーが発生しました。

The latest bundler is 1.16.2, but you are currently running 1.15.3.
To update, run `gem install bundler`
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root users
on this machine.
Your Gemfile lists the gem poltergeist (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of one of them later.
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 12.0.0
Using i18n 0.7.0
Using minitest 5.10.3
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using rack 1.6.8
Using mime-types-data 3.2016.0521
Using arel 6.0.4
Using public_suffix 2.0.5
Using bundler 1.15.3
Using coderay 1.1.1
Using concurrent-ruby 1.0.5
Using temple 0.8.0
Using tilt 2.0.8
Using htmlentities 4.3.4
Using httpclient 2.8.3
Using thor 0.20.0
Using liquid 2.6.3
Using mimemagic 0.3.2
Using net-ldap 0.12.1
Using pg 0.18.4
Using ruby-openid 2.3.0
Using rbpdf-font 1.19.1
Using redcarpet 3.4.0
Using request_store 1.0.5
Fetching rmagick 2.16.0
Installing rmagick 2.16.0 with native extensions
Using rubyzip 1.2.1
Using tzinfo 1.2.3
Using nokogiri 1.7.2
Using rack-test 0.6.3
Using mime-types 3.1
Using addressable 2.5.1
Using sprockets 3.7.1
Using haml 5.0.3
Using rack-openid 1.4.2
Using rbpdf 1.19.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/usr/local/lib/ruby/gems/2.4.0/gems/rmagick-2.16.0/ext/RMagick
/usr/local/bin/ruby -r ./siteconf20180609-2440-1w7nf25.rb extconf.rb
checking for gcc... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
/usr/local/lib/ruby/2.4.0/mkmf.rb:457:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/2.4.0/mkmf.rb:588:in `try_cpp'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:1095:in `block in have_header'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:945:in `block in checking_for'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:321:in `open'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:351:in `block in postpone'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:321:in `open'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:347:in `postpone'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:944:in `checking_for'
from /usr/local/lib/ruby/2.4.0/mkmf.rb:1094:in `have_header'
from extconf.rb:39:in `configure_headers'
from extconf.rb:18:in `initialize'
from extconf.rb:548:in `new'
from extconf.rb:548:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/rmagick-2.16.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/usr/local/lib/ruby/gems/2.4.0/gems/rmagick-2.16.0 for inspection.
Results logged to
/usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/rmagick-2.16.0/gem_make.out
An error occurred while installing rmagick (2.16.0), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.16.0'` succeeds before bundling.
In Gemfile:
rmagick

yumでインストールしていたImageMagickが古すぎる?でもImageMagick7は新しすぎてrmagickが対応できていない…じゃあImageMagick6の最新(6.9.9)をインストールする?など、色々対応してみましたが、最終的にはまったく異なる原因でした。

https://stackoverflow.com/questions/48998558/gcc-error-libgomp-spec-no-such-file-or-directory-with-amazon-linux-2017-09-1

実は、/usr/lib64に必要なファイルが無かったのが原因のようです。。

要因は分からないですが、どうやら/usr/libにあるファイルをシンボリックリンクで作成すれば動きました…(なぜ?)

sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/7/libgomp.spec /usr/lib64/libgomp.spec
sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/7/libgomp.a /usr/lib64/libgomp.a
sudo ln -s /usr/lib64/libgomp.so.1.0.0 /usr/lib64/libgomp.so

とりあえず、上記のようにシンボリックリンクを貼って動かすと、正常にインストールすることができました。

なんで無かったんだろう…