我们在Heroku上使用Googlechrome和chromedriver在无头浏览器中渲染一些HTML。这以前是有效的,但现在失败并出现以下错误。
Selenium::WebDriver::Error::UnknownError: unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.4.0-1019-aws x86_64)
通过按如下方式从命令行运行谷歌浏览器来解决此问题也会失败:
~ $ /app/.apt/usr/bin/google-chrome-stable
/app/.apt/opt/google/chrome/chrome: /lib/x86_64-linux-gnu/libdbus-1.so.3: no version information available (required by /app/.apt/usr/lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0)
/app/.apt/opt/google/chrome/chrome: /lib/x86_64-linux-gnu/libdbus-1.so.3: no version information available (required by /app/.apt/usr/lib/x86_64-linux-gnu/libatspi.so.0)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmirclient.so.9)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmirclient.so.9)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmirclient.so.9)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmircommon.so.7)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmircommon.so.7)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmircommon.so.7)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmircore.so.1)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libmircore.so.1)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so.9)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0)
/app/.apt/opt/google/chrome/chrome: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /app/.apt/usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0)
必须修补 heroku xvfb chrome buildpack,不确定是否真的需要 libstdc++6 作为额外的包:
diff --git a/bin/compile b/bin/compile
index 6d092e9..ead9239 100755
--- a/bin/compile
+++ b/bin/compile
@@ -67,7 +67,7 @@ esac
indent "Installing Google Chrome from the $channel channel."
-PACKAGES="https://dl.google.com/linux/direct/google-chrome-${channel}_current_amd64.deb libxss1 libnss3 xvfb"
+PACKAGES="libstdc++6 https://dl.google.com/linux/direct/google-chrome-${channel}_current_amd64.deb libxss1 libnss3 xvfb"
APT_CACHE_DIR="$CACHE_DIR/apt/cache"
APT_STATE_DIR="$CACHE_DIR/apt/state"
@@ -146,7 +146,8 @@ BIN_DIR=$BUILD_DIR/.apt/usr/bin
rm $BIN_DIR/$SHIM
cat <<EOF >$BIN_DIR/$SHIM
#!/usr/bin/env bash
-exec $HOME/.apt/opt/google/$BIN --disable-gpu --no-sandbox $@
+export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
+$HOME/.apt/opt/google/$BIN --disable-gpu --no-sandbox $@
EOF
chmod +x $BIN_DIR/$SHIM
cp $BIN_DIR/$SHIM $BIN_DIR/google-chrome
看起来这是 Heroku 上使用的构建包和堆栈组合的问题。
构建包跟踪Chrome的最新稳定版本,而不是特定版本。看起来没有办法锁定版本,因此从Chrome更新最新版本可能会导致chrome失败
https://github.com/heroku/heroku-buildpack-google-chrome#channels
对我们来说,将构建包从Cedar-14
升级到Heroku-16
意味着/app/.apt/usr/bin/google-chrome-stable
将再次成功运行 chrome。