0
0

More than 1 year has passed since last update.

An error occurred while installing libv8-node (16.10.0.0)

Posted at

Railsプロジェクトはmini_racerを使っていますね。
bundle installを実行する時、以下のようなmini_racerインストールはエラーがよく発生しました。

/home/bunbu/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/libv8-node-16.10.0.0/src/node-v16.10.0/out/Release/icupkg: /lib64/libstdc++.so.6: version
`CXXABI_1.3.9' not found (required by
  make: *** [/home/bunbu/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/libv8-node-16.10.0.0/src/node-v16.10.0/out/Release/obj/gen/icudt69l.dat] Error

問題なのはGCCバージョンが古いですから。
エラーを解決する方法をまとめました。

※ 環境
ー Centos 7
ー Rails 6.1.4.7
ー mini_racer
ー libv8-node 16.10.0.0

1. まず、GCCバージョンを更新する

Centos 7ではデフォルトGCC最新バージョンが4.8.5のようです。
YUMで4.8.5より新しいバージョンをインストールできないです。
ですので、ソースコードからインストールしましょう。
gcc 7.3.0をインストールしてみました。

wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-7.3.0/gcc-7.3.0.tar.gz
tar zxf gcc-7.3.0.tar.gz
cd gcc-7.3.0
sudo yum -y install bzip2
./contrib/download_prerequisites
./configure --disable-multilib --enable-languages=c,c++
make -j 4
sudo make install

2. v8-devel再インストール

libv8-nodeが使うライブラリです。
最新版をインストールしましょう。

sudo yum remove v8-devel
sudo yum install v8-devel

3. CXXABIをチョックする

gcc 7.3.0をインストールできたが、libstdc++が古い版を参照しているケースがありますね。

strings /usr/lib64/libstdc++.so.6 | grep CXXABI

バージョン1.3.9がない場合、以下のコマンドで修正します。

# libstdcを探す
ls /usr/local/lib64 | grep libstdc++

# 私のPCでは6.0.28が最新です。
cp /usr/local/lib64/libstdc++.so.6.0.28 /usr/lib64/
cd /usr/lib64/
rm -rf libstdc++.so.6
ln -s libstdc++.so.6.0.28 libstdc++.so.6

これでRailsプロジェクトフォルダーでbundle installを再実行して、問題なくインストールできるはずだと思います。

0
0
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
0
0