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

[BUG] log cleanup procedure runs when logs-max=0 and throws error on permissions but not missing directory #6270

Closed
2 tasks done
jmealo opened this issue Mar 17, 2023 · 0 comments · Fixed by #6271
Closed
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@jmealo
Copy link
Contributor

jmealo commented Mar 17, 2023

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When running npm with logs_max=0 npm still attempts to run the log cleanup routine. This routine attempts to scandir. If this is happening in CI where npm is being invoked as root this causes a permission error and warning to be output for every npm run command:

[2023-03-10T19:21:39.786Z] npm WARN logfile Error: EACCES: permission denied, scandir '/root/.npm/_logs'
[2023-03-10T19:21:39.786Z] npm WARN logfile  error cleaning log files [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
[2023-03-10T19:21:39.786Z] npm WARN logfile   errno: -13,
[2023-03-10T19:21:39.786Z] npm WARN logfile   code: 'EACCES',
[2023-03-10T19:21:39.786Z] npm WARN logfile   syscall: 'scandir',
[2023-03-10T19:21:39.786Z] npm WARN logfile   path: '/root/.npm/_logs'
[2023-03-10T19:21:39.786Z] npm WARN logfile }

What's odd though, is if the directory is non-existent, no warning is printed.

Expected Behavior

The cleanup routine not to run when logs_max=0.
To not have warnings for every npm run command in CI :)

Steps To Reproduce

  1. Using official Node docker images
  2. Running as a user that doesn't have permission to write to the logs directory (try running as the root user)
  3. Run any npm run command with logs-max=0 in the .npmrc or NPM_CONFIG_LOGS_MAX= on the env
  4. The cleanup routine will still attempt to run and will print a warning

Environment

  • npm: 8.19.2
  • Node.js: v18.12.1
  • OS Name: MacOS
  • System Model Name: MacBook Pro (14-inch, 2021) [Apple M1 Pro]
  • npm config:
always-auth = false 
engine-strict = true
logs-max = 0
@jmealo jmealo added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Mar 17, 2023
@jmealo jmealo changed the title [BUG] log cleanup procedure runs when logs_max=0 throws error on permissions but not missing directory [BUG] log cleanup procedure runs when logs-max=0 and throws error on permissions but not missing directory Mar 17, 2023
jmealo added a commit to jmealo/cli that referenced this issue Mar 22, 2023
jmealo added a commit to jmealo/cli that referenced this issue Mar 22, 2023
jmealo added a commit to jmealo/cli that referenced this issue Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant