Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: use ~/.cache/puppeteer for browser downloads #9095

Merged
merged 1 commit into from Oct 11, 2022
Merged

Conversation

jrandolf
Copy link
Contributor

@jrandolf jrandolf commented Oct 11, 2022

This PR moves browser downloads into ~/.cache/puppeteer to make use of global caching. This allows for better, cross-project installation of browsers and simplifies the location of browsers.

Previously, Puppeteer download Chromium to .local_chromium wherever your puppeteer-core was installed.

Now, Puppeteer will download Chromium into $PUPPETEER_CACHE_DIR/chrome (where PUPPETEER_CACHE_DIR defaults to ~/.cache/puppeteer).

Synonymous statements can be said for Firefox.

@jrandolf jrandolf force-pushed the revision branch 11 times, most recently from 94f64e7 to df29159 Compare October 11, 2022 09:58
@jrandolf jrandolf marked this pull request as ready for review October 11, 2022 09:58
@jrandolf jrandolf requested a review from OrKoN October 11, 2022 09:58
@jrandolf jrandolf enabled auto-merge (squash) October 11, 2022 10:29
@jrandolf jrandolf enabled auto-merge (squash) October 11, 2022 11:20
@jrandolf jrandolf merged commit 3df375b into main Oct 11, 2022
@jrandolf jrandolf deleted the revision branch October 11, 2022 11:20
mhan83 added a commit to saucelabs/puppeteer-replay-runner that referenced this pull request Oct 14, 2022
As of puppeteer@19, browser downloads go to ~/.cache/puppeteer and not
into .local_chromium (see
puppeteer/puppeteer#9095)
mhan83 added a commit to saucelabs/puppeteer-replay-runner that referenced this pull request Oct 14, 2022
* bump deps

* Update bundle script

As of puppeteer@19, browser downloads go to ~/.cache/puppeteer and not
into .local_chromium (see
puppeteer/puppeteer#9095)
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 24, 2022
This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 24, 2022
This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 24, 2022
We override `PUPPETEER_CACHE_DIR` to a directory inside the workspace so that this can be persisted. As access to parent directories is not allowed in circle ci when using persist_to_workspace.

This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 24, 2022
We override `PUPPETEER_CACHE_DIR` to a directory inside the workspace so that this can be persisted. As access to parent directories is not allowed in circle ci when using persist_to_workspace.

This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 24, 2022
We override `PUPPETEER_CACHE_DIR` to a directory inside the workspace so that this can be persisted. As access to parent directories is not allowed in circle ci when using persist_to_workspace.

This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 24, 2022
We override `PUPPETEER_CACHE_DIR` to a directory inside the workspace so that this can be persisted. As access to parent directories is not allowed in circle ci when using persist_to_workspace.

This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 24, 2022
We override `PUPPETEER_CACHE_DIR` to a directory inside the workspace so that this can be persisted. As access to parent directories is not allowed in circle ci when using persist_to_workspace.

This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 25, 2022
This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 25, 2022
This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this pull request Oct 25, 2022
This is needed due to the breaking change in version 19 puppeteer/puppeteer#9095
@xcbaojian
Copy link

xcbaojian commented Nov 4, 2022

After this upgrade, Ubuntu shows some errors when running. This seems to be a problem with the chrome path. The error that is eventually reported after relying on the installation is difficult to solve. Note that this is the case with Ubuntu.

[00:16:30] /root/workspace/pupperteer_WcJ8/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:299
[00:16:30]             reject(new Error([
[00:16:30]                    ^
[00:16:30] 
[00:16:30] Error: Failed to launch the browser process!
[00:16:30] /root/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome: /lib/x86_64-linux-gnu/libdbus-1.so.3: no version information available (required by /root/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome)
[00:16:30] /root/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by /root/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome)
[00:16:30] /root/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome: symbol lookup error: /root/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome: undefined symbol: gbm_bo_get_modifier
[00:16:30] 
[00:16:30] 
[00:16:30] TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
[00:16:30] 
[00:16:30]     at onClose (/root/workspace/pupperteer_WcJ8/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:299:20)

const puppeteer = require('puppeteer');
const moment = require('moment');
console.log(moment().format("YYYY-MM-DD HH:mm:ss"));  

(async () => {
  // const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] })

const pathToExtension = '/root/.cache/puppeteer/chrome/linux-1056772/chrome-linux/chrome';
const browser = await puppeteer.launch({
   headless: true,
   timeout: 0, 
   devtools: true, 
   executablePath: pathToExtension,
   args:['--disable-infobars','--no-sandbox','--disable-setuid-sandbox']
   });
  const page = await browser.newPage();
  await page.goto('https://www.google.com');
  await page.screenshot({path: 'example110401.png'});

  await browser.close();
})();

This PR moves browser downloads into ~/.cache/puppeteer to make use of global caching. This allows for better, cross-project installation of browsers and simplifies the location of browsers.

Previously, Puppeteer download Chromium to .local_chromium wherever your puppeteer-core was installed.

Now, Puppeteer will download Chromium into $PUPPETEER_CACHE_DIR/chrome (where PUPPETEER_CACHE_DIR defaults to ~/.cache/puppeteer).

Synonymous statements can be said for Firefox.

This PR moves browser downloads into ~/.cache/puppeteer to make use of global caching. This allows for better, cross-project installation of browsers and simplifies the location of browsers.

Previously, Puppeteer download Chromium to .local_chromium wherever your puppeteer-core was installed.

Now, Puppeteer will download Chromium into $PUPPETEER_CACHE_DIR/chrome (where PUPPETEER_CACHE_DIR defaults to ~/.cache/puppeteer).

Synonymous statements can be said for Firefox.

@WilliamDEdwards
Copy link

WilliamDEdwards commented Jan 25, 2024

How do I restore the previous behaviour on new versions?

When Puppeteer is installed globally by root, this change causes Chrome to be inaccessible for regular users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants