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

PUPPETEER_DOWNLOAD_PATH does not support relative paths #7592

Closed
thesam opened this issue Sep 23, 2021 · 3 comments
Closed

PUPPETEER_DOWNLOAD_PATH does not support relative paths #7592

thesam opened this issue Sep 23, 2021 · 3 comments

Comments

@thesam
Copy link

thesam commented Sep 23, 2021

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 10.4.0
  • Platform / OS version: Ubuntu 21.04
  • URLs (if applicable):
  • Node.js version: v14.17.6

We set the Puppeteer download path in our project's .npmrc. We want to store the downloaded Chromium outside node_modules to avoid downloading it everytime we run "npm ci".

We want to use a relative path to make sure it works for all our users, on both Windows and Linux.

What steps will reproduce the problem?

  1. Set PUPPETEER_DOWNLOAD_PATH with a relative path using an environment variable, npm config or .npmrc.
  2. Install puppeteer

For example:

PUPPETEER_DOWNLOAD_PATH=../bar npx puppeteer

What is the expected result?
Puppeteer downloads Chromium to ../bar.

What happens instead?
The extract-zip library requires an absolute path and throws an Error.

Downloading Chromium r901912 - 140.9 Mb [====================] 99% 0.0s 
ERROR: Failed to set up Chromium r901912! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
Error: Target directory is expected to be absolute
    at Object.module.exports [as default] (/home/user/.npm/_npx/34327/lib/node_modules/puppeteer/node_modules/extract-zip/index.js:167:11)
    at install (/home/user/.npm/_npx/34327/lib/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:392:37)
    at BrowserFetcher.download (/home/user/.npm/_npx/34327/lib/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:249:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async downloadBrowser (/home/user/.npm/_npx/34327/lib/node_modules/puppeteer/lib/cjs/puppeteer/node/install.js:51:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer@10.4.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the puppeteer@10.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@jschfflr
Copy link
Contributor

@thesam Thanks for your report! Please feel free to create a pull request for this and I'm happy to get it landed :)

nadir added a commit to nadir/puppeteer that referenced this issue Sep 29, 2021
This patch fixes the BrowserFetcher._getFolderPath method so that it supports relative download paths using PUPPETEER_DOWNLOAD_PATH or npm config

Issues: puppeteer#7592
nadir added a commit to nadir/puppeteer that referenced this issue Sep 29, 2021
This patch fixes the BrowserFetcher._getFolderPath method so that it supports relative download paths using PUPPETEER_DOWNLOAD_PATH or npm config

Issues: puppeteer#7592
jschfflr pushed a commit that referenced this issue Sep 29, 2021
This patch fixes the BrowserFetcher._getFolderPath method so that it supports relative download paths using PUPPETEER_DOWNLOAD_PATH or npm config

Issues: #7592
@jschfflr
Copy link
Contributor

jschfflr commented Oct 7, 2021

Closing this as the pull request has already been merged.

@vedantroy
Copy link

Getting the error:

npm ERR! command sh -c node install.js
npm ERR! ERROR: Failed to set up Chrome r114.0.5735.133! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
npm ERR! Error: Target directory is expected to be absolute
npm ERR!     at module.exports (/home/vedantroy/Desktop/llms/gensite/js/node_modules/extract-zip/index.js:167:11)
npm ERR!     at unpackArchive (/home/vedantroy/Desktop/llms/gensite/js/node_modules/@puppeteer/browsers/lib/cjs/fileUtil.js:59:41)
npm ERR!     at install (/home/vedantroy/Desktop/llms/gensite/js/node_modules/@puppeteer/browsers/lib/cjs/install.js:106:51)
npm ERR!     at async downloadBrowser (/home/vedantroy/Desktop/llms/gensite/js/node_modules/puppeteer/lib/cjs/puppeteer/node/install.js:51:24)

For puppeteer:

    "puppeteer": "^20.7.3"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment