てしりこじり

しりがちいさいエンジニアがいるという

g++ commnd not found で eventmachine のインストールに失敗

Ubuntu14.04 で Ruby2.2.0 を利用して bundle install 中にエラー。

g++ が見つからずに eventmachine のインストールに失敗しているみたい。

エラー内容
$ bundle install --path vendor/bundle
…
compiling rubymain.cpp
make: g++: コマンドが見つかりませんでした
make: *** [rubymain.o] エラー 127

make failed, exit code 2

Gem files will remain installed in /home/hoge/app/vendor/bundle/ruby/2.2.0/gems/eventmachine-1.0.4 for inspection.
Results logged to /home/hoge/app/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0-static/eventmachine-1.0.4/gem_make.out
An error occurred while installing eventmachine (1.0.4), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.0.4'` succeeds before bundling.
対応

g++ を導入する。
gcc は入れたんだけど。パラパラいれるのがよくないのか。。。
build-essential のインストールでよいみたいなので導入。

sudo apt-get install build-essential

再実行

$ bundle install --path vendor/bundle
…
Installing eventmachine 1.0.4
…

成功したよ!