Add CHROME_VERSION envvar for later buildpacks #95
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reason why I send this PR
Send this PR because lots of https://github.com/heroku/heroku-buildpack-chromedriver users (including me) encountered the chromedirver and Chrome version mismatch problem (
This version of ChromeDriver only supports Chrome version XX
) so often and some of these users even create issues in here:Although heroku-buildpack-chromedriver has a feature which you can set the
CHROMEDIRVER_VERSION
config var in Heroku dashboard to make it install the specific version of chromedriver.But, It's annoying that if I push my code to Heroku once a while. It will download the new version Chrome and new version chromedriver then this problem shows again. (Same for new users.)
I have to login to the console, check the version of Chrome, modify the
CHROMEDIRVER_VERSION
config var and make Heroku rebuild my app again to solve this problem.So, I came out with a idea:
"What if heroku-buildpack-chromedriver can install the same version of chromedriver for the Chrome installed by heroku-buildpack-google-chrome automatically?"
At first, I was trying to solve this problem in heroku-buildpack-chromedriver without sending PR to this upstream repo.
But, after spent some time on digging out the code, realizing how it works and testing on my own Heroku app.
I found out I cannot get the version of Chrome installed by heroku-buildpack-google-chrome.
Although it did
export PATH="$BUILD_DIR/.apt/usr/bin:$PATH"
for later buildpacks inheroku-buildpack-google-chrome/bin/compile
Lines 156 to 165 in e85ed96
I thought I could easily use
google-chrome --version
to get it in the heroku-buildpack-chromedriver building process, so I don't need to send a PR to this repo. Since there's a alias$BUILD_DIR/.apt/usr/bin/google-chrome
been created atheroku-buildpack-google-chrome/bin/compile
Lines 172 to 186 in e85ed96
But, I was wrong. The problem is that alias points to the
$HOME
. During the building process, all things are still in the$BUILD_DIR
, not copied to$HOME
yet. So, I got the error message while testing my patch:/tmp/build_04cb8278/.apt/usr/bin/google-chrome: line 3: /app/.apt/opt/google/chrome/chrome: No such file or directory
I am not sure if late buildpack use the same
$BUILD_DIR
as the previous buildpack, But even if so, I had to call$BUILD_DIR/.apt/opt/google/$BIN --product-version
to get the version of Chrome. The problem is$BIN
is decided by the$channel
in this repo:heroku-buildpack-google-chrome/bin/compile
Lines 41 to 58 in e85ed96
I don't think it's a good idea to find all the possible executables in a downstream repo. So, that's the reason why I am here to send this PR.
Detail
So, I have to get the
CRHOME_VERSION
from$BUILD_DIR/.apt/opt/google/$BIN --product-version
which is the absolute path of the downloaded Chrome.Export it for the later buildpacks, which is heroku-buildpack-chromedriver here. So, it will know what version of chromedriver to download. (Of course, Need to modify the code of heroku-buildpack-chromedirver.)
Review
After using my patches of these two repos to build my Heroku App:
It works like a charm on Heroku-18.

Here's a part of the build log:
The version of Chrome installed by heroku-buildpack-google-chrome And the version of chromedirver installed by patched heroku-buildpack-chromedriver (app name erased for safety reason):

Further
If this PR could be merged, I think it can also solve another PR: #78
Hope this PR could be merged.
Any further discussions are welcome.
Thank you and appreciate your time for reading this long PR description.