我们在Heroku上使用Google chrome 和 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)
答案 0 :(得分:1)
必须修补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
答案 1 :(得分:0)
似乎这是Heroku上使用的buildpack和stacks组合的问题。
构建包会跟踪Chrome的最新稳定版本,而不是特定版本。似乎无法锁定版本,因此Chrome的最新更新可能会导致chrome失败
https://github.com/heroku/heroku-buildpack-google-chrome#channels
对我们来说,将构建包从Cedar-14
升级到Heroku-16
意味着/app/.apt/usr/bin/google-chrome-stable
将再次成功运行chrome。