lighthouse-ci icon indicating copy to clipboard operation
lighthouse-ci copied to clipboard

Make `.lighthouseci` configurable

Open synergychen opened this issue 4 years ago • 5 comments

Describe the bug

When I change outputDir to be /tmp/lhci rather than default .lighhouseci, and make .lighthouseci read only (due to our env constraints and security concerns, all project folder are read only except for /tmp), then I will not be able to run lhci command to generate any report.

To Reproduce Steps to reproduce the behavior:

  1. Change .lighthouseci to read only: chmod -wx .lighthouseci.
  2. Add upload.outputDir = '/tmp/lhci' to lighthouserc.js.
  3. Run lhci healthcheck or lhci collect or lhci autorun.
  4. All commands will fail because .lighthouseci is not writable even though a different output directory is defined.

Expected behavior If outputDir is defined to a different writable folder other than default .lighthouseci, I will expect health check will run against the new folder rather than .lighthouseci.

Logs/Screenshots

When I run lhci healthcheck, it will show:

❌  .lighthouseci/ directory not writable
    ERROR: EACCES: permission denied, open '/Users/ch/src/example-node-express/.lighthouseci/lhr-1629210143850.json'
✅  Configuration file found
✅  Chrome installation found
Healthcheck failed!

When I run lhci collect, it will show:

Error: EACCES: permission denied, unlink '/Users/ch/src/example-node-express/.lighthouseci/lhr-1629210143850.html'
    at Object.unlinkSync (fs.js:1155:3)
    at clearSavedReportsAndLHRs (/Users/ch/.nvm/versions/node/v14.1.0/lib/node_modules/@lhci/cli/node_modules/@lhci/utils/src/saved-reports.js:65:8)
    at Object.runCommand (/Users/ch/.nvm/versions/node/v14.1.0/lib/node_modules/@lhci/cli/src/collect/collect.js:231:26)
    at run (/Users/ch/.nvm/versions/node/v14.1.0/lib/node_modules/@lhci/cli/src/cli.js:103:24)
    at Object.<anonymous> (/Users/ch/.nvm/versions/node/v14.1.0/lib/node_modules/@lhci/cli/src/cli.js:137:1)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)%

Environment (please complete the following information):

  • OS: [Mac OSX]
  • Version [0.8.0]
  • Node Version [14.1.0]

synergychen avatar Aug 17 '21 15:08 synergychen

Thanks for filing @synergychen! This is expected behavior.

.lighthouseci is not the output dir, but a temporary working directory used regardless of whether upload is ever invoked.

At the moment this is not a customizable property, but we can let this issue track that feature request.

patrickhulce avatar Aug 17 '21 17:08 patrickhulce

@patrickhulce Thanks for the update! Is there any workaround or hacky way at the moment that could skip the writable .lighthouse check if I want to write the output to different folder?

synergychen avatar Aug 17 '21 18:08 synergychen

@synergychen cd to a different directory within /tmp before running LHCI or edit node_modules/@lhci/utils/src/saved-reports.js to whatever directory you'd like.

https://github.com/GoogleChrome/lighthouse-ci/blob/932a5fe98412df705e98e0866600c176db790212/packages/utils/src/saved-reports.js#L10

patrickhulce avatar Aug 17 '21 19:08 patrickhulce

Great, thanks!

synergychen avatar Aug 18 '21 12:08 synergychen

Anyone can help me fix that please

shell: /bin/bash -e {0} 4 env: 5 FORCE_COLOR: 1 6 ✅ .lighthouseci/ directory writable 7 ⚠️ Configuration file not found 8 ✅ Chrome installation found 9 Healthcheck passed!

stanleySimeon avatar Feb 23 '22 13:02 stanleySimeon