Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.2k stars 9.68k forks source link

use ~/Library/Logs for service logs #18487

Closed itcarroll closed 3 weeks ago

itcarroll commented 3 weeks ago

Verification

Provide a detailed description of the proposed feature

Services that use the log_path and error_log_path variables typically use var/"log/...", so they are writable only by the user that installs homebrew. The services are installed as ~/Library/LaunchAgents and run as per-user agents. Would you consider writing logs to ~/Library/Logs/ so any user can run the service without permission errors?

What is the motivation for the feature?

The jupyterlab formula defines a service that includes log_path var/"log/jupyterlab.log". I'm unable to get this service to work in a multi-user setup using the suggested (maybe supported? unclear) installation with a user dedicated for Homebrew.

User "homebrew" (the only user that can brew install anything) installs the package and can use the service. Any other user can brew services start jupyterlab but the service has an error. The error arises because permission is denied for logging. If brew services start .... could set the log_path to ~/Library/Logs/jupyterlab.log then the service ought to work for all users.

How will the feature be relevant to at least 90% of Homebrew users?

Maybe to 90% of brew services users (this is probably a small percentage of Homebrew users) would benefit, because ~/Library/Logs/ is the typical place to expect logs from per-user agents.

What alternatives to the feature have been considered?

I have tried to understand if there is a way to use the HOME environment variable in the plist file, but there does not seem to be any support for this at the launchd level. I think the ~ would have to be expanded when the service file is created by Homebrew.

Redirected to request here in Homebrew/homebrew-services#759.

MikeMcQuaid commented 3 weeks ago

Would you consider writing logs to ~/Library/Logs/ so any user can run the service without permission errors?

No, sorry, this is long-running, expected behaviour for Homebrew at this point.

suggested (maybe supported? unclear) installation with a user dedicated for Homebrew

This is not a supported Homebrew configuration, unfortunately.

If brew services start .... could set the log_path to ~/Library/Logs/jupyterlab.log then the service ought to work for all users.

Many other services store their data in var and would need read/write permission in there so the log_path is just the tip of the iceberg here.

Redirected to request here in Homebrew/homebrew-services#759.

Apologies for the confusion here but: I didn't request an issue here but that you attempt a pull request for your specific request i.e. making this something that might be possible in a formula's service block.