You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The linux() function in find-chrome.ts doesn't check $CHROME_PATH, but an error message incorrectly suggests setting $CHROME_PATH in certain situations.
#840
Open
nerikeshi-k opened this issue
Mar 1, 2024
· 0 comments
> storycap --serverCmd="npx serve dist-storybook -p 6006" http://localhost:6006 "--outDir=.vrt/expected"
info Wait for connecting storybook server http://localhost:6006.
error The environment variable CHROME_PATH must be set to executable of a build of Chromium version 54.0 or later.
Error: The environment variable CHROME_PATH must be set to executable of a build of Chromium version 54.0 or later.
at linux (/home/neriko/misc/vrt-artifacts/node_modules/.pnpm/[email protected]/node_modules/storycrawler/lib/find-chrome.js:126:15)
at findChrome (/home/neriko/misc/vrt-artifacts/node_modules/.pnpm/[email protected]/node_modules/storycrawler/lib/find-chrome.js:163:30)
at StoriesBrowser.boot (/home/neriko/misc/vrt-artifacts/node_modules/.pnpm/[email protected]/node_modules/storycrawler/lib/browser/base-browser.js:47:71)
at main (/home/neriko/misc/vrt-artifacts/node_modules/.pnpm/[email protected]/node_modules/storycap/lib/node/main.js:45:101)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async time (/home/neriko/misc/vrt-artifacts/node_modules/.pnpm/[email protected]/node_modules/storycrawler/lib/timer.js:14:20)
I attempted to set the environment variable CHROME_PATH as suggested by the error message but it didn't solve the issue.
I suspect the function to find the Chromium binary on Linux, named linux(), might be partly incorrect. It seems to use $CHROME_PATH only for calculating priority, but does not search within $CHROME_PATH. linux() is here:
Remove the code related to $CHROME_PATH as its current use might be causing unintended behaviors. Here is an example:
/** * Look for linux executables in 2 ways * 1. Look into the directories where .desktop are saved on gnome based distro's * 2. Look for google-chrome-stable & google-chrome executables by using the which command */functionlinux(_canary=false): string|undefined{letinstallations: string[]=[];// Look into the directories where .desktop are saved on gnome based distro'sconstdesktopInstallationFolders=[path.join(require('os').homedir(),'.local/share/applications/'),'/usr/share/applications/',];desktopInstallationFolders.forEach(folder=>{installations=installations.concat(findChromeExecutables(folder));});// Look for google-chrome(-stable) & chromium(-browser) executables by using the which commandconstexecutables=['google-chrome-stable','google-chrome','chromium-browser','chromium'];executables.forEach(executable=>{try{constchromePath=execFileSync('which',[executable],{stdio: 'pipe'}).toString().split(newLineRegex)[0];if(canAccess(chromePath))installations.push(chromePath);}catch(e){// Not installed.}});constpriorities=[{regex: /chrome-wrapper$/,weight: 51},{regex: /google-chrome-stable$/,weight: 50},{regex: /google-chrome$/,weight: 49},{regex: /chromium-browser$/,weight: 48},{regex: /chromium$/,weight: 47},];returnsort(uniq(installations.filter(Boolean)),priorities)[0]??undefined;}
Make the function search within $CHROME_PATH. Here's an example:
/*** Look for linux executables in 3 ways* 1. Look into CHROME_PATH env variable* 2. Look into the directories where .desktop are saved on gnome based distro's* 3. Look for google-chrome-stable & google-chrome executables by using the which command*/functionlinux(_canary=false){letinstallations: string[]=[];// Add CHROME_PATH if definedif(process.env.CHROME_PATH)installations.push(process.env.CHROME_PATH);// Look into the directories where .desktop are saved on gnome based distro'sconstdesktopInstallationFolders=[path.join(require('os').homedir(),'.local/share/applications/'),'/usr/share/applications/',];desktopInstallationFolders.forEach(folder=>{installations=installations.concat(findChromeExecutables(folder));});// Look for google-chrome(-stable) & chromium(-browser) executables by using the which commandconstexecutables=['google-chrome-stable','google-chrome','chromium-browser','chromium'];executables.forEach(executable=>{try{constchromePath=execFileSync('which',[executable],{stdio: 'pipe'}).toString().split(newLineRegex)[0];if(canAccess(chromePath))installations.push(chromePath);}catch(e){// Not installed.}});if(!installations.length)thrownewError('The environment variable CHROME_PATH must be set to executable of a build of Chromium version 54.0 or later.',);constpriorities=[{regex: /chrome-wrapper$/,weight: 51},{regex: /google-chrome-stable$/,weight: 50},{regex: /google-chrome$/,weight: 49},{regex: /chromium-browser$/,weight: 48},{regex: /chromium$/,weight: 47},];if(process.env.CHROME_PATH)priorities.unshift({regex: newRegExp(`${process.env.CHROME_PATH}`),weight: 101});returnsort(uniq(installations.filter(Boolean)),priorities)[0];}
If either way 1 or 2 looks ok, I'm going to create a pull request. Thank you!
The text was updated successfully, but these errors were encountered:
Thank you for this great project!
Problem I encountered
Environment:
~/.cache/puppeteer/chrome/linux-122.0.6261.69/chrome-linux64/chrome
~/.local/share/applications/
/usr/share/applications/
google-chrome-stable
,google-chrome
,chromium-browser
, norchromium
are set in $PATHThe Storycap CLI command I ran:
$ storycap --serverCmd=\"npx serve dist-storybook -p 6006\" http://localhost:6006"
The error message I received:
I attempted to set the environment variable CHROME_PATH as suggested by the error message but it didn't solve the issue.
I suspect the function to find the Chromium binary on Linux, named
linux()
, might be partly incorrect. It seems to use$CHROME_PATH
only for calculating priority, but does not search within$CHROME_PATH
.linux()
is here:storycap/packages/storycrawler/src/find-chrome.ts
Lines 103 to 148 in 7c22231
Suggestions
I see two possible solutions:
If either way 1 or 2 looks ok, I'm going to create a pull request. Thank you!
The text was updated successfully, but these errors were encountered: