Opened 8 months ago
Last modified 4 months ago
#73237 assigned enhancement
Feature request: Improve error message when Portfile cannot be opened due to insufficient privileges
| Reported by: | judaew (Vadym-Valdis Yudaiev) | Owned by: | |
|---|---|---|---|
| Priority: | Normal | Milestone: | |
| Component: | base | Version: | 2.11.6 |
| Keywords: | sequoia, x86_64 | Cc: | judaew (Vadym-Valdis Yudaiev), petrrr |
| Port: |
Description (last modified by judaew (Vadym-Valdis Yudaiev))
After updating from 2.11.5 to 2.11.6, I initially thought I had hit a bug because the following error appeared when trying to build a local port. However, after Ryan’s explanation, it became clear that this is expected behavior: the macports user simply lacks the necessary permissions to read the Portfile in this location.
Still, it would be helpful to provide a clearer and more informative message for users who encounter this for the first time.
$ sudo port install -dt pre-commit
DEBUG: Opening port in directory: /Users/judaew/wrk/github.com/judaew/macports-ports/python/pre-commit
...
DEBUG: Sourcing PortGroup python 1.0 from /Users/judaew/wrk/github.com/judaew/macports-ports/_resources/port1.0/group/python-1.0.tcl
...
DEBUG: Running callback python_add_dependencies
DEBUG: Finished running callback python_add_dependencies
DEBUG: dropping privileges: euid changed to 502, egid changed to 501.
DEBUG: Could not open file: /Users/judaew/wrk/github.com/judaew/macports-ports/python/pre-commit/Portfile
while executing
"sha256 file ${portpath}/Portfile"
(procedure "open_statefile" line 24)
invoked from within
"open_statefile"
Error: Failed to open statefile for pre-commit: Could not open file: /Users/judaew/wrk/github.com/judaew/macports-ports/python/pre-commit/Portfile
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port pre-commit failed
Change History (8)
comment:1 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)
comment:2 Changed 8 months ago by judaew (Vadym-Valdis Yudaiev)
Thank you for the clarification the additional context helped me look at the error from a different angle. Given that the macports user runs with minimal privileges, the behavior now makes sense, and in this light it doesn’t appear to be a bug.
However, I’d like to suggest adding a small explanatory message in Port for cases like this. A brief hint about why the error occurs and how to resolve it (e.g., o-x permissions or move to ${prefix}) would make the issue clearer for users encountering it for the first time.
comment:3 Changed 8 months ago by judaew (Vadym-Valdis Yudaiev)
| Description: | modified (diff) |
|---|---|
| Summary: | Error: Failed to open statefile for <port>: Could not open file <file> → Feature request: Improve error message when statefile cannot be opened due to insufficient privileges |
| Type: | defect → request |
comment:4 Changed 8 months ago by jmroot (Joshua Root)
| Summary: | Feature request: Improve error message when statefile cannot be opened due to insufficient privileges → Feature request: Improve error message when Portfile cannot be opened due to insufficient privileges |
|---|---|
| Type: | request → enhancement |
comment:5 Changed 8 months ago by jmroot (Joshua Root)
| Owner: | jmroot deleted |
|---|
comment:6 follow-up: 7 Changed 8 months ago by robcd (Rob Dickens)
… would make the issue clearer for users encountering it for the first time.
#me-too. Very despair-inducing. Thanks for submitting this!
Btw, what is the best practice here?
I had put the Portfile in ~me/Devt/MacPorts/local/<category>/<port>/, where me has no admin privileges.
Please could sb just spell out what I should do so that the macports user can read it.
Thanks for reading.
comment:7 Changed 8 months ago by robcd (Rob Dickens)
Replying to robcd:
Btw, what is the best practice here?
Okay - must be to do what guide says.
Please could sb just spell out what I should do so that the macports user can read it.
Okay - should have read above link. Solved using ACLs.
comment:8 Changed 4 months ago by petrrr
| Cc: | petrrr added |
|---|

This is intended. See https://lists.macports.org/pipermail/macports-dev/2025-October/046528.html and follow-ups.