CentOS7で実行ファイルの不足している依存関係を解消する(CentOS7でElectronが試せない話に関連して)

[前回](https://qiita.com/one-kelvin/items/3da99a5fe4d8856feb55)、CentOS7でElectronを試そうとしたら起動すらできませんでした。前回のエラーの解消はできたのですが、今度は別のエラーが発生してElectronの起動自体はまだできていません。しかし、今回はCentOS7上での実行ファイルの依存関係を解決する方法の一つがわかったのではないかと思ったので、前回に引き続きまとめておきます。

# エラーのおさらい

`electron1`というディレクトリの中で、`electron-quick-start`を丸パクリしたファイルが置いてあります。

```
$ pwd
/vagrant/electron1
$ ls -la
index.html  main.js  node_modules  package-lock.json  package.json  renderer.js
```

ここで実行すると

```
$ npm run start

> electron1@1.0.0 start /vagrant/electron1
> electron .

/vagrant/electron1/node_modules/electron/dist/electron: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! electron1@1.0.0 start: `electron .`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the electron1@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-11-24T02_01_25_328Z-debug.log
```

こういうエラーが出ていました。

# 共有ライブラリの依存関係を調べる。

「error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory」で検索しました。このエラーメッセージはElectronに限らずいろんな状況で出ているようですね。
検索結果のうちの[こちらのページ](https://confluence.sharuru07.jp/pages/viewpage.action?pageId=360736)を参考にやってみます。

エラー内容をもう一度読んでみると、`node_modules/electron/dist/electron`とありますがこれはバイナリファイルです。名前的におそらくElectronの実行ファイルでしょう。この実行ファイルを動かすときに不足しているものがあるようです。実行ファイルの依存関係を`ldd`コマンドで調べます。[lddコマンドについて](http://itpro.nikkeibp.co.jp/article/COLUMN/20140127/532486/?rt=nocnt)


```
$ ldd /vagrant/electron1/node_modules/electron/dist/electron
	linux-vdso.so.1 =>  (0x00007fffa34a7000)
	libnode.so => /vagrant/electron1/node_modules/electron/dist/libnode.so (0x00007f7904917000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f79046ef000)
	libgtk-x11-2.0.so.0 => not found
	libgdk-x11-2.0.so.0 => not found
	libpangocairo-1.0.so.0 => /lib64/libpangocairo-1.0.so.0 (0x00007f79044e1000)
	libatk-1.0.so.0 => /lib64/libatk-1.0.so.0 (0x00007f79042bb000)
	libcairo.so.2 => /lib64/libcairo.so.2 (0x00007f7903f93000)
	libgdk_pixbuf-2.0.so.0 => /lib64/libgdk_pixbuf-2.0.so.0 (0x00007f7903d6a000)
	libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007f79039d6000)
	libpango-1.0.so.0 => /lib64/libpango-1.0.so.0 (0x00007f790378b000)
	libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f790353a000)
	libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f7903294000)
	libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f7903057000)
	libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007f7902e0e000)
	libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007f7902c0c000)
	libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f79029e4000)
	libXi.so.6 => not found
	libXcursor.so.1 => not found
	libXdamage.so.1 => /lib64/libXdamage.so.1 (0x00007f79027e0000)
	libXrandr.so.2 => /lib64/libXrandr.so.2 (0x00007f79025d4000)
	libXcomposite.so.1 => not found
	libXext.so.6 => /lib64/libXext.so.6 (0x00007f79023c2000)
	libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007f79021bb000)
	libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f7901fb0000)
	libX11.so.6 => /lib64/libX11.so.6 (0x00007f7901c72000)
	libXtst.so.6 => not found
	libXss.so.1 => not found
	libgconf-2.so.4 => not found
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f7901a6c000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f7901864000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f7901552000)
	libnss3.so => /lib64/libnss3.so (0x00007f7901227000)
	libnssutil3.so => /lib64/libnssutil3.so (0x00007f7900ffa000)
	libsmime3.so => /lib64/libsmime3.so (0x00007f7900dd3000)
	libnspr4.so => /lib64/libnspr4.so (0x00007f7900b94000)
	libffmpeg.so => /vagrant/electron1/node_modules/electron/dist/libffmpeg.so (0x00007f79004f5000)
	libasound.so.2 => not found
	libcups.so.2 => not found
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f79002f0000)
	libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f79000c6000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f78ffdbd000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f78ffabb000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f78ff8a5000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f78ff4e1000)
	/lib64/ld-linux-x86-64.so.2 (0x00005643583ce000)
	libpangoft2-1.0.so.0 => /lib64/libpangoft2-1.0.so.0 (0x00007f78ff2cb000)
	libthai.so.0 => /lib64/libthai.so.0 (0x00007f78ff0bf000)
	libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f78feebc000)
	libharfbuzz.so.0 => /lib64/libharfbuzz.so.0 (0x00007f78fec59000)
	libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007f78fe9b0000)
	libEGL.so.1 => /lib64/libEGL.so.1 (0x00007f78fe782000)
	libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f78fe557000)
	libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f78fe353000)
	libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f78fe144000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f78fdf2e000)
	libGL.so.1 => /lib64/libGL.so.1 (0x00007f78fdcbc000)
	libffi.so.6 => /lib64/libffi.so.6 (0x00007f78fdab3000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f78fd851000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f78fd62a000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f78fd40f000)
	libmount.so.1 => /lib64/libmount.so.1 (0x00007f78fd1ce000)
	libXau.so.6 => /lib64/libXau.so.6 (0x00007f78fcfc9000)
	libplc4.so => /lib64/libplc4.so (0x00007f78fcdc4000)
	libplds4.so => /lib64/libplds4.so (0x00007f78fcbbf000)
	libgraphite2.so.3 => /lib64/libgraphite2.so.3 (0x00007f78fc991000)
	libxcb-dri2.so.0 => /lib64/libxcb-dri2.so.0 (0x00007f78fc78b000)
	libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007f78fc583000)
	libxcb-dri3.so.0 => /lib64/libxcb-dri3.so.0 (0x00007f78fc380000)
	libxcb-present.so.0 => /lib64/libxcb-present.so.0 (0x00007f78fc17c000)
	libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007f78fbf75000)
	libxshmfence.so.1 => /lib64/libxshmfence.so.1 (0x00007f78fbd72000)
	libgbm.so.1 => /lib64/libgbm.so.1 (0x00007f78fbb65000)
	libdrm.so.2 => /lib64/libdrm.so.2 (0x00007f78fb956000)
	libglapi.so.0 => /lib64/libglapi.so.0 (0x00007f78fb726000)
	libxcb-glx.so.0 => /lib64/libxcb-glx.so.0 (0x00007f78fb50b000)
	libXxf86vm.so.1 => /lib64/libXxf86vm.so.1 (0x00007f78fb305000)
	libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f78fb0c5000)
	libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f78faec0000)
```

`not found`になっているものが`libgtk-x11-2.0.so.0`以外にも9個あります。`libgtk-x11-2.0.so.0`インストールしたはず、、、とか思いましたができていなかったようです。この不足分をインストールします。

# 不足しているライブラリのインストール

無いなら入れましょうということでyumからインストールします。先に言っておくと`yum install`ではうまくいきません。

```
$ sudo yum install -y libgtk-x11-2.0.so.0 libgdk-x11-2.0.so.0 libXi.so.6 libXcursor.so.1 libXcomposite.so.1 libXtst.so.6 libXss.so.1 libgconf-2.so.4 libasound.so.2 libcups.so.2

...
完了しました!
```

再度依存関係を調べましょう

```
$ ldd /vagrant/electron1/node_modules/electron/dist/electron
	linux-vdso.so.1 =>  (0x00007ffe6a5a7000)
	libnode.so => /vagrant/electron1/node_modules/electron/dist/libnode.so (0x00007fad3b667000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fad3b43f000)
	libgtk-x11-2.0.so.0 => not found
	libgdk-x11-2.0.so.0 => not found
	libpangocairo-1.0.so.0 => /lib64/libpangocairo-1.0.so.0 (0x00007fad3b231000)
	libatk-1.0.so.0 => /lib64/libatk-1.0.so.0 (0x00007fad3b00b000)
	libcairo.so.2 => /lib64/libcairo.so.2 (0x00007fad3ace3000)
	libgdk_pixbuf-2.0.so.0 => /lib64/libgdk_pixbuf-2.0.so.0 (0x00007fad3aaba000)
	libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007fad3a726000)
	libpango-1.0.so.0 => /lib64/libpango-1.0.so.0 (0x00007fad3a4db000)
	libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007fad3a28a000)
	libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007fad39fe4000)
	libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007fad39da7000)
	libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007fad39b5e000)
	libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007fad3995c000)
	libxcb.so.1 => /lib64/libxcb.so.1 (0x00007fad39734000)
	libXi.so.6 => not found
	libXcursor.so.1 => not found
	libXdamage.so.1 => /lib64/libXdamage.so.1 (0x00007fad39530000)
	libXrandr.so.2 => /lib64/libXrandr.so.2 (0x00007fad39324000)
	libXcomposite.so.1 => not found
	libXext.so.6 => /lib64/libXext.so.6 (0x00007fad39112000)
	libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007fad38f0b000)
	libXrender.so.1 => /lib64/libXrender.so.1 (0x00007fad38d00000)
	libX11.so.6 => /lib64/libX11.so.6 (0x00007fad389c2000)
	libXtst.so.6 => not found
	libXss.so.1 => not found
	libgconf-2.so.4 => not found
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007fad387bc000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fad385b4000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007fad382a2000)
	libnss3.so => /lib64/libnss3.so (0x00007fad37f77000)
	libnssutil3.so => /lib64/libnssutil3.so (0x00007fad37d4a000)
	libsmime3.so => /lib64/libsmime3.so (0x00007fad37b23000)
	libnspr4.so => /lib64/libnspr4.so (0x00007fad378e4000)
	libffmpeg.so => /vagrant/electron1/node_modules/electron/dist/libffmpeg.so (0x00007fad37245000)
	libasound.so.2 => not found
	libcups.so.2 => not found
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fad37040000)
	libexpat.so.1 => /lib64/libexpat.so.1 (0x00007fad36e16000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fad36b0d000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fad3680b000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fad365f5000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fad36231000)
	/lib64/ld-linux-x86-64.so.2 (0x000055e996581000)
	libpangoft2-1.0.so.0 => /lib64/libpangoft2-1.0.so.0 (0x00007fad3601b000)
	libthai.so.0 => /lib64/libthai.so.0 (0x00007fad35e0f000)
	libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007fad35c0c000)
	libharfbuzz.so.0 => /lib64/libharfbuzz.so.0 (0x00007fad359a9000)
	libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007fad35700000)
	libEGL.so.1 => /lib64/libEGL.so.1 (0x00007fad354d2000)
	libpng15.so.15 => /lib64/libpng15.so.15 (0x00007fad352a7000)
	libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007fad350a3000)
	libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007fad34e94000)
	libz.so.1 => /lib64/libz.so.1 (0x00007fad34c7e000)
	libGL.so.1 => /lib64/libGL.so.1 (0x00007fad34a0c000)
	libffi.so.6 => /lib64/libffi.so.6 (0x00007fad34803000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fad345a1000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fad3437a000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fad3415f000)
	libmount.so.1 => /lib64/libmount.so.1 (0x00007fad33f1e000)
	libXau.so.6 => /lib64/libXau.so.6 (0x00007fad33d19000)
	libplc4.so => /lib64/libplc4.so (0x00007fad33b14000)
	libplds4.so => /lib64/libplds4.so (0x00007fad3390f000)
	libgraphite2.so.3 => /lib64/libgraphite2.so.3 (0x00007fad336e1000)
	libxcb-dri2.so.0 => /lib64/libxcb-dri2.so.0 (0x00007fad334db000)
	libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007fad332d3000)
	libxcb-dri3.so.0 => /lib64/libxcb-dri3.so.0 (0x00007fad330d0000)
	libxcb-present.so.0 => /lib64/libxcb-present.so.0 (0x00007fad32ecc000)
	libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007fad32cc5000)
	libxshmfence.so.1 => /lib64/libxshmfence.so.1 (0x00007fad32ac2000)
	libgbm.so.1 => /lib64/libgbm.so.1 (0x00007fad328b5000)
	libdrm.so.2 => /lib64/libdrm.so.2 (0x00007fad326a6000)
	libglapi.so.0 => /lib64/libglapi.so.0 (0x00007fad32476000)
	libxcb-glx.so.0 => /lib64/libxcb-glx.so.0 (0x00007fad3225b000)
	libXxf86vm.so.1 => /lib64/libXxf86vm.so.1 (0x00007fad32055000)
	libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fad31e15000)
	libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fad31c10000)
```

依存関係を解消するためには、不足しているファイルをyumからインストールしてもだめで、ファイルが含まれるパッケージをインストールしてあげる必要があります。


# 不足しているライブラリがどのパッケージに入っているか調べる

`not found`になっているライブラリはパッケージの添付ファイルとして提供されるようです。`yum whatprovides`コマンドで不足しているライブラリがどのパッケージに入っているかを調べます。

```
$ yum whatprovides */libgtk-x11-2.0.so.0
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
extras/7/x86_64/filelists_db                             | 494 kB     00:00     
mongodb-org-3.4/7/filelists_db                           | 6.4 kB     00:00     
updates/7/x86_64/filelists_db                            | 2.1 MB     00:01     
gtk2-2.24.31-1.el7.i686 : The GIMP ToolKit (GTK+), a library for creating GUIs
                        : for X
リポジトリー        : base
一致          :
ファイル名    : /usr/lib/libgtk-x11-2.0.so.0



gtk2-2.24.31-1.el7.x86_64 : The GIMP ToolKit (GTK+), a library for creating GUIs
                          : for X
リポジトリー        : base
一致          :
ファイル名    : /usr/lib64/libgtk-x11-2.0.so.0



gtk2-2.24.31-1.el7.i686 : The GIMP ToolKit (GTK+), a library for creating GUIs
                        : for X
リポジトリー        : @base
一致          :
ファイル名    : /usr/lib/libgtk-x11-2.0.so.0
```

`libgtk-x11-2.0.so.0`ファイルは`gtk2`というパッケージに含まれるようです。インストールして再度依存関係を調べます。

```
$ sudo yum install -y gtk2

...
完了しました!
[vagrant@localhost electron1]$ ldd /vagrant/electron1/node_modules/electron/dist/electron
	linux-vdso.so.1 =>  (0x00007ffd15b88000)
	libnode.so => /vagrant/electron1/node_modules/electron/dist/libnode.so (0x00007f87aaf2b000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f87aad03000)
	libgtk-x11-2.0.so.0 => /lib64/libgtk-x11-2.0.so.0 (0x00007f87aa681000)
	libgdk-x11-2.0.so.0 => /lib64/libgdk-x11-2.0.so.0 (0x00007f87aa3c0000)
	libpangocairo-1.0.so.0 => /lib64/libpangocairo-1.0.so.0 (0x00007f87aa1b2000)
	libatk-1.0.so.0 => /lib64/libatk-1.0.so.0 (0x00007f87a9f8c000)
	libcairo.so.2 => /lib64/libcairo.so.2 (0x00007f87a9c64000)
	libgdk_pixbuf-2.0.so.0 => /lib64/libgdk_pixbuf-2.0.so.0 (0x00007f87a9a3b000)
	libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007f87a96a7000)
	libpango-1.0.so.0 => /lib64/libpango-1.0.so.0 (0x00007f87a945c000)
	libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f87a920b000)
	libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f87a8f65000)
	libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f87a8d28000)
	libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007f87a8adf000)
	libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007f87a88dd000)
	libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f87a86b5000)
	libXi.so.6 => /lib64/libXi.so.6 (0x00007f87a84a4000)
	libXcursor.so.1 => /lib64/libXcursor.so.1 (0x00007f87a8299000)
	libXdamage.so.1 => /lib64/libXdamage.so.1 (0x00007f87a8096000)
	libXrandr.so.2 => /lib64/libXrandr.so.2 (0x00007f87a7e8a000)
	libXcomposite.so.1 => /lib64/libXcomposite.so.1 (0x00007f87a7c87000)
	libXext.so.6 => /lib64/libXext.so.6 (0x00007f87a7a75000)
	libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007f87a786e000)
	libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f87a7663000)
	libX11.so.6 => /lib64/libX11.so.6 (0x00007f87a7325000)
	libXtst.so.6 => not found
	libXss.so.1 => not found
	libgconf-2.so.4 => not found
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f87a711f000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f87a6f17000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f87a6c05000)
	libnss3.so => /lib64/libnss3.so (0x00007f87a68da000)
	libnssutil3.so => /lib64/libnssutil3.so (0x00007f87a66ad000)
	libsmime3.so => /lib64/libsmime3.so (0x00007f87a6486000)
	libnspr4.so => /lib64/libnspr4.so (0x00007f87a6247000)
	libffmpeg.so => /vagrant/electron1/node_modules/electron/dist/libffmpeg.so (0x00007f87a5ba8000)
	libasound.so.2 => not found
	libcups.so.2 => /lib64/libcups.so.2 (0x00007f87a593e000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f87a573a000)
	libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f87a5510000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f87a5207000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f87a4f05000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f87a4cef000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f87a492b000)
	/lib64/ld-linux-x86-64.so.2 (0x0000560f98cd3000)
	libpangoft2-1.0.so.0 => /lib64/libpangoft2-1.0.so.0 (0x00007f87a4715000)
	libXinerama.so.1 => /lib64/libXinerama.so.1 (0x00007f87a4511000)
	libthai.so.0 => /lib64/libthai.so.0 (0x00007f87a4305000)
	libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f87a4103000)
	libharfbuzz.so.0 => /lib64/libharfbuzz.so.0 (0x00007f87a3e9f000)
	libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007f87a3bf6000)
	libEGL.so.1 => /lib64/libEGL.so.1 (0x00007f87a39c9000)
	libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f87a379d000)
	libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f87a3599000)
	libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f87a338b000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f87a3174000)
	libGL.so.1 => /lib64/libGL.so.1 (0x00007f87a2f02000)
	libffi.so.6 => /lib64/libffi.so.6 (0x00007f87a2cf9000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f87a2a97000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f87a2870000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f87a2656000)
	libmount.so.1 => /lib64/libmount.so.1 (0x00007f87a2414000)
	libXau.so.6 => /lib64/libXau.so.6 (0x00007f87a2210000)
	libplc4.so => /lib64/libplc4.so (0x00007f87a200a000)
	libplds4.so => /lib64/libplds4.so (0x00007f87a1e06000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f87a1bb8000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f87a18d0000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f87a169d000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f87a1498000)
	libssl.so.10 => /lib64/libssl.so.10 (0x00007f87a1226000)
	libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f87a0dc5000)
	libavahi-common.so.3 => /lib64/libavahi-common.so.3 (0x00007f87a0bb7000)
	libavahi-client.so.3 => /lib64/libavahi-client.so.3 (0x00007f87a09a6000)
	libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f87a076f000)
	libgraphite2.so.3 => /lib64/libgraphite2.so.3 (0x00007f87a0540000)
	libxcb-dri2.so.0 => /lib64/libxcb-dri2.so.0 (0x00007f87a033b000)
	libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007f87a0132000)
	libxcb-dri3.so.0 => /lib64/libxcb-dri3.so.0 (0x00007f879ff2f000)
	libxcb-present.so.0 => /lib64/libxcb-present.so.0 (0x00007f879fd2c000)
	libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007f879fb24000)
	libxshmfence.so.1 => /lib64/libxshmfence.so.1 (0x00007f879f921000)
	libgbm.so.1 => /lib64/libgbm.so.1 (0x00007f879f715000)
	libdrm.so.2 => /lib64/libdrm.so.2 (0x00007f879f505000)
	libglapi.so.0 => /lib64/libglapi.so.0 (0x00007f879f2d6000)
	libxcb-glx.so.0 => /lib64/libxcb-glx.so.0 (0x00007f879f0ba000)
	libXxf86vm.so.1 => /lib64/libXxf86vm.so.1 (0x00007f879eeb4000)
	libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f879ec74000)
	libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f879ea6f000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f879e861000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f879e65c000)
	libfreebl3.so => /lib64/libfreebl3.so (0x00007f879e459000)
```

6個分の`not found`が解消されました。1個のパッケージを入れることで、複数ファイルが入ることもあるようです。同じようにして残りもやってみます。

```
$ yum whatprovides */libXtst.so.6
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
libXtst-1.2.3-1.el7.i686 : X.Org X11 libXtst runtime library
リポジトリー        : base
一致          :
ファイル名    : /usr/lib/libXtst.so.6



libXtst-1.2.3-1.el7.x86_64 : X.Org X11 libXtst runtime library
リポジトリー        : base
一致          :
ファイル名    : /usr/lib64/libXtst.so.6



libXtst-1.2.3-1.el7.i686 : X.Org X11 libXtst runtime library
リポジトリー        : @base
一致          :
ファイル名    : /usr/lib/libXtst.so.6
```

`libXtst.so.6`ファイルは`libXtst`パッケージに含まれるようです。

```
$ sudo yum install -y libXtst

...
完了しました!
$ ldd /vagrant/electron1/node_modules/electron/dist/electron
	linux-vdso.so.1 =>  (0x00007ffebcb4b000)
	libnode.so => /vagrant/electron1/node_modules/electron/dist/libnode.so (0x00007efeb127c000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007efeb1054000)
	libgtk-x11-2.0.so.0 => /lib64/libgtk-x11-2.0.so.0 (0x00007efeb09d2000)
	libgdk-x11-2.0.so.0 => /lib64/libgdk-x11-2.0.so.0 (0x00007efeb0711000)
	libpangocairo-1.0.so.0 => /lib64/libpangocairo-1.0.so.0 (0x00007efeb0503000)
	libatk-1.0.so.0 => /lib64/libatk-1.0.so.0 (0x00007efeb02dd000)
	libcairo.so.2 => /lib64/libcairo.so.2 (0x00007efeaffb5000)
	libgdk_pixbuf-2.0.so.0 => /lib64/libgdk_pixbuf-2.0.so.0 (0x00007efeafd8c000)
	libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007efeaf9f8000)
	libpango-1.0.so.0 => /lib64/libpango-1.0.so.0 (0x00007efeaf7ad000)
	libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007efeaf55c000)
	libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007efeaf2b6000)
	libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007efeaf079000)
	libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007efeaee30000)
	libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007efeaec2e000)
	libxcb.so.1 => /lib64/libxcb.so.1 (0x00007efeaea06000)
	libXi.so.6 => /lib64/libXi.so.6 (0x00007efeae7f5000)
	libXcursor.so.1 => /lib64/libXcursor.so.1 (0x00007efeae5ea000)
	libXdamage.so.1 => /lib64/libXdamage.so.1 (0x00007efeae3e7000)
	libXrandr.so.2 => /lib64/libXrandr.so.2 (0x00007efeae1db000)
	libXcomposite.so.1 => /lib64/libXcomposite.so.1 (0x00007efeadfd8000)
	libXext.so.6 => /lib64/libXext.so.6 (0x00007efeaddc6000)
	libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007efeadbbf000)
	libXrender.so.1 => /lib64/libXrender.so.1 (0x00007efead9b4000)
	libX11.so.6 => /lib64/libX11.so.6 (0x00007efead676000)
	libXtst.so.6 => /lib64/libXtst.so.6 (0x00007efead46f000)
	libXss.so.1 => not found
	libgconf-2.so.4 => not found
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007efead26a000)
	librt.so.1 => /lib64/librt.so.1 (0x00007efead062000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007efeacd50000)
	libnss3.so => /lib64/libnss3.so (0x00007efeaca25000)
	libnssutil3.so => /lib64/libnssutil3.so (0x00007efeac7f8000)
	libsmime3.so => /lib64/libsmime3.so (0x00007efeac5d1000)
	libnspr4.so => /lib64/libnspr4.so (0x00007efeac392000)
	libffmpeg.so => /vagrant/electron1/node_modules/electron/dist/libffmpeg.so (0x00007efeabcf3000)
	libasound.so.2 => not found
	libcups.so.2 => /lib64/libcups.so.2 (0x00007efeaba89000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007efeab885000)
	libexpat.so.1 => /lib64/libexpat.so.1 (0x00007efeab65b000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007efeab352000)
	libm.so.6 => /lib64/libm.so.6 (0x00007efeab050000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007efeaae3a000)
	libc.so.6 => /lib64/libc.so.6 (0x00007efeaaa76000)
	/lib64/ld-linux-x86-64.so.2 (0x000055b0dcb25000)
	libpangoft2-1.0.so.0 => /lib64/libpangoft2-1.0.so.0 (0x00007efeaa860000)
	libXinerama.so.1 => /lib64/libXinerama.so.1 (0x00007efeaa65c000)
	libthai.so.0 => /lib64/libthai.so.0 (0x00007efeaa450000)
	libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007efeaa24e000)
	libharfbuzz.so.0 => /lib64/libharfbuzz.so.0 (0x00007efea9fea000)
	libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007efea9d41000)
	libEGL.so.1 => /lib64/libEGL.so.1 (0x00007efea9b14000)
	libpng15.so.15 => /lib64/libpng15.so.15 (0x00007efea98e8000)
	libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007efea96e4000)
	libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007efea94d6000)
	libz.so.1 => /lib64/libz.so.1 (0x00007efea92bf000)
	libGL.so.1 => /lib64/libGL.so.1 (0x00007efea904d000)
	libffi.so.6 => /lib64/libffi.so.6 (0x00007efea8e44000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007efea8be2000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007efea89bb000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007efea87a1000)
	libmount.so.1 => /lib64/libmount.so.1 (0x00007efea855f000)
	libXau.so.6 => /lib64/libXau.so.6 (0x00007efea835b000)
	libplc4.so => /lib64/libplc4.so (0x00007efea8155000)
	libplds4.so => /lib64/libplds4.so (0x00007efea7f51000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007efea7d03000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007efea7a1b000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007efea77e8000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007efea75e3000)
	libssl.so.10 => /lib64/libssl.so.10 (0x00007efea7371000)
	libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007efea6f10000)
	libavahi-common.so.3 => /lib64/libavahi-common.so.3 (0x00007efea6d02000)
	libavahi-client.so.3 => /lib64/libavahi-client.so.3 (0x00007efea6af1000)
	libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007efea68ba000)
	libgraphite2.so.3 => /lib64/libgraphite2.so.3 (0x00007efea668b000)
	libxcb-dri2.so.0 => /lib64/libxcb-dri2.so.0 (0x00007efea6486000)
	libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007efea627d000)
	libxcb-dri3.so.0 => /lib64/libxcb-dri3.so.0 (0x00007efea607a000)
	libxcb-present.so.0 => /lib64/libxcb-present.so.0 (0x00007efea5e77000)
	libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007efea5c6f000)
	libxshmfence.so.1 => /lib64/libxshmfence.so.1 (0x00007efea5a6c000)
	libgbm.so.1 => /lib64/libgbm.so.1 (0x00007efea5860000)
	libdrm.so.2 => /lib64/libdrm.so.2 (0x00007efea5650000)
	libglapi.so.0 => /lib64/libglapi.so.0 (0x00007efea5421000)
	libxcb-glx.so.0 => /lib64/libxcb-glx.so.0 (0x00007efea5205000)
	libXxf86vm.so.1 => /lib64/libXxf86vm.so.1 (0x00007efea4fff000)
	libblkid.so.1 => /lib64/libblkid.so.1 (0x00007efea4dbf000)
	libuuid.so.1 => /lib64/libuuid.so.1 (0x00007efea4bba000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007efea49ac000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007efea47a7000)
	libfreebl3.so => /lib64/libfreebl3.so (0x00007efea45a4000)
```

1個分解消されました。残り3つが含まれるパッケージを調べると、`libXScrnSaver`、`GConf2`、`alsa-lib`と分かったので、これらをインストールして依存関係の不足が解消されたか調べます。

```
$ sudo yum install -y libXScrnSaver GConf2 alsa-lib

...
完了しました!
$ ldd /vagrant/electron1/node_modules/electron/dist/electron
	linux-vdso.so.1 =>  (0x00007ffec5571000)
	libnode.so => /vagrant/electron1/node_modules/electron/dist/libnode.so (0x00007f5cbb08e000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5cbae66000)
	libgtk-x11-2.0.so.0 => /lib64/libgtk-x11-2.0.so.0 (0x00007f5cba7e4000)
	libgdk-x11-2.0.so.0 => /lib64/libgdk-x11-2.0.so.0 (0x00007f5cba523000)
	libpangocairo-1.0.so.0 => /lib64/libpangocairo-1.0.so.0 (0x00007f5cba315000)
	libatk-1.0.so.0 => /lib64/libatk-1.0.so.0 (0x00007f5cba0ef000)
	libcairo.so.2 => /lib64/libcairo.so.2 (0x00007f5cb9dc7000)
	libgdk_pixbuf-2.0.so.0 => /lib64/libgdk_pixbuf-2.0.so.0 (0x00007f5cb9b9e000)
	libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007f5cb980a000)
	libpango-1.0.so.0 => /lib64/libpango-1.0.so.0 (0x00007f5cb95bf000)
	libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f5cb936e000)
	libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f5cb90c8000)
	libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f5cb8e8b000)
	libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007f5cb8c42000)
	libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007f5cb8a40000)
	libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f5cb8818000)
	libXi.so.6 => /lib64/libXi.so.6 (0x00007f5cb8607000)
	libXcursor.so.1 => /lib64/libXcursor.so.1 (0x00007f5cb83fc000)
	libXdamage.so.1 => /lib64/libXdamage.so.1 (0x00007f5cb81f9000)
	libXrandr.so.2 => /lib64/libXrandr.so.2 (0x00007f5cb7fed000)
	libXcomposite.so.1 => /lib64/libXcomposite.so.1 (0x00007f5cb7dea000)
	libXext.so.6 => /lib64/libXext.so.6 (0x00007f5cb7bd8000)
	libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007f5cb79d1000)
	libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f5cb77c6000)
	libX11.so.6 => /lib64/libX11.so.6 (0x00007f5cb7488000)
	libXtst.so.6 => /lib64/libXtst.so.6 (0x00007f5cb7281000)
	libXss.so.1 => /lib64/libXss.so.1 (0x00007f5cb707d000)
	libgconf-2.so.4 => /lib64/libgconf-2.so.4 (0x00007f5cb6e4c000)
	libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f5cb6c47000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f5cb6a3f000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f5cb672d000)
	libnss3.so => /lib64/libnss3.so (0x00007f5cb6402000)
	libnssutil3.so => /lib64/libnssutil3.so (0x00007f5cb61d5000)
	libsmime3.so => /lib64/libsmime3.so (0x00007f5cb5fae000)
	libnspr4.so => /lib64/libnspr4.so (0x00007f5cb5d6f000)
	libffmpeg.so => /vagrant/electron1/node_modules/electron/dist/libffmpeg.so (0x00007f5cb56d0000)
	libasound.so.2 => /lib64/libasound.so.2 (0x00007f5cb53d2000)
	libcups.so.2 => /lib64/libcups.so.2 (0x00007f5cb5168000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f5cb4f64000)
	libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f5cb4d3a000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f5cb4a31000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f5cb472f000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f5cb4519000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f5cb4155000)
	/lib64/ld-linux-x86-64.so.2 (0x000055efdb1b2000)
	libpangoft2-1.0.so.0 => /lib64/libpangoft2-1.0.so.0 (0x00007f5cb3f3f000)
	libXinerama.so.1 => /lib64/libXinerama.so.1 (0x00007f5cb3d3b000)
	libthai.so.0 => /lib64/libthai.so.0 (0x00007f5cb3b2f000)
	libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f5cb392d000)
	libharfbuzz.so.0 => /lib64/libharfbuzz.so.0 (0x00007f5cb36c9000)
	libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007f5cb3420000)
	libEGL.so.1 => /lib64/libEGL.so.1 (0x00007f5cb31f3000)
	libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f5cb2fc7000)
	libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f5cb2dc3000)
	libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f5cb2bb5000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f5cb299e000)
	libGL.so.1 => /lib64/libGL.so.1 (0x00007f5cb272c000)
	libffi.so.6 => /lib64/libffi.so.6 (0x00007f5cb2523000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f5cb22c1000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f5cb209a000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f5cb1e80000)
	libmount.so.1 => /lib64/libmount.so.1 (0x00007f5cb1c3e000)
	libXau.so.6 => /lib64/libXau.so.6 (0x00007f5cb1a3a000)
	libdbus-glib-1.so.2 => /lib64/libdbus-glib-1.so.2 (0x00007f5cb1811000)
	libplc4.so => /lib64/libplc4.so (0x00007f5cb160c000)
	libplds4.so => /lib64/libplds4.so (0x00007f5cb1408000)
	libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f5cb11ba000)
	libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f5cb0ed2000)
	libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f5cb0c9e000)
	libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f5cb0a9a000)
	libssl.so.10 => /lib64/libssl.so.10 (0x00007f5cb0828000)
	libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f5cb03c6000)
	libavahi-common.so.3 => /lib64/libavahi-common.so.3 (0x00007f5cb01b9000)
	libavahi-client.so.3 => /lib64/libavahi-client.so.3 (0x00007f5caffa8000)
	libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f5cafd70000)
	libgraphite2.so.3 => /lib64/libgraphite2.so.3 (0x00007f5cafb42000)
	libxcb-dri2.so.0 => /lib64/libxcb-dri2.so.0 (0x00007f5caf93c000)
	libxcb-xfixes.so.0 => /lib64/libxcb-xfixes.so.0 (0x00007f5caf734000)
	libxcb-dri3.so.0 => /lib64/libxcb-dri3.so.0 (0x00007f5caf531000)
	libxcb-present.so.0 => /lib64/libxcb-present.so.0 (0x00007f5caf32d000)
	libxcb-sync.so.1 => /lib64/libxcb-sync.so.1 (0x00007f5caf126000)
	libxshmfence.so.1 => /lib64/libxshmfence.so.1 (0x00007f5caef23000)
	libgbm.so.1 => /lib64/libgbm.so.1 (0x00007f5caed16000)
	libdrm.so.2 => /lib64/libdrm.so.2 (0x00007f5caeb07000)
	libglapi.so.0 => /lib64/libglapi.so.0 (0x00007f5cae8d7000)
	libxcb-glx.so.0 => /lib64/libxcb-glx.so.0 (0x00007f5cae6bc000)
	libXxf86vm.so.1 => /lib64/libXxf86vm.so.1 (0x00007f5cae4b6000)
	libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f5cae276000)
	libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f5cae071000)
	libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f5cade62000)
	libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f5cadc5e000)
	libfreebl3.so => /lib64/libfreebl3.so (0x00007f5cada5a000)
```

`not found`がなくなりました。不足しているライブラリは無いようなので、electronを実行してみます。

```
$ npm run start

> electron1@1.0.0 start /vagrant/electron1
> electron .

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron1@1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron1@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-11-24T03_00_57_794Z-debug.log
```

今まで出ていたエラーは解消されたようですが、別のエラーが起きています。Electronはまだ実行できていません。

# まとめ

実行ファイルの依存関係が不足しているというエラーが発生したときは

- `ldd 実行ファイル名`で`not found`になっているファイルを探す
- `yum whatprovides */not foundになったファイル名`で`not found`になっているコマンドが含まれるパッケージを探す(見つかったファイルを直接`yum install`してもだめ)
- `sudo yum install -y 見つけたパッケージ名`コマンドで不足している依存関係を解消する
- `ldd 実行ファイル名`で解消されたかを確かめる

これの繰り返しで依存関係の不足が解消されるはず。という内容でした。