heroku / heroku-buildpack-google-chrome

[DEPRECATED] Classic buildpack that installs Google Chrome.
296 stars 365 forks source link

Add CHROME_VERSION envvar for later buildpacks #95

Closed fkztw closed 6 months ago

fkztw commented 4 years ago

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 in https://github.com/heroku/heroku-buildpack-google-chrome/blob/e85ed96d67c05d35fd1488948c16603b4e4b8717/bin/compile#L156-L165 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 at https://github.com/heroku/heroku-buildpack-google-chrome/blob/e85ed96d67c05d35fd1488948c16603b4e4b8717/bin/compile#L172-L186 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: https://github.com/heroku/heroku-buildpack-google-chrome/blob/e85ed96d67c05d35fd1488948c16603b4e4b8717/bin/compile#L41-L58 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: 20200910_16:12:19

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): 20200910_16:15:05


Further

If this PR could be merged, I think it can also solve another PR: https://github.com/heroku/heroku-buildpack-google-chrome/pull/78

Hope this PR could be merged. Any further discussions are welcome. Thank you and appreciate your time for reading this long PR description.

CrazybutSolid commented 4 years ago

+1.

Chrome 85 broke my app. Need to find a way to stick with Chrome 84!

fkztw commented 4 years ago

@CrazybutSolid This PR cannot make you stick with Chrome 84. It will still download the latest version of Chrome from https://dl.google.com/linux/direct/google-chrome-${channel}_current_amd64.deb

kandluis commented 4 years ago

+1

CrazybutSolid commented 3 years ago

@CrazybutSolid This PR cannot make you stick with Chrome 84. It will still download the latest version of Chrome from https://dl.google.com/linux/direct/google-chrome-${channel}_current_amd64.deb

What can I do make it stick to Chrome 84. I still haven't been able to stabilize it

arsandov commented 3 years ago

I think this is useful! Our build just got broke due the new Chrome 93.

xyNNN commented 3 years ago

What's the state of this pull request?

edmorley commented 6 months ago

Hi! Sorry for the delayed reply. This buildpack has been deprecated in favour of the newer (and hopefully more robust) Chrome for Testing buildpack: https://blog.heroku.com/improved-browser-testing-on-heroku-with-chrome https://github.com/heroku/heroku-buildpack-chrome-for-testing

As such, I'm closing this out.