Robust Host Ownership Realignment for Containerized Scaffolding #4
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
luchaveztech/larakube-cli!4
Loading…
Reference in a new issue
No description provided.
Delete branch "inv3ntor01/permission-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
During
larakube new, scaffolding is handled by a root-run Docker container. Once finished, the CLI attempts to return file ownership to the host user via a chown command. This breaks down in two waysHardcoded Fallback: The CLI checks your host ID using posix_getuid(). If that PHP extension is missing, it blindly defaults to UID 1000. If the host user runs on a non-standard ID (like 1001), subsequent file modifications (such as copying .env to .env.production) crash with a Permission Denied fatal error.
Short-Circuit Execution: The cleanup command is chained using && (e.g., laravel new ... && chown ...). If the repository installation fails or times out, the chown is skipped entirely, leaving orphaned, root-owned files in the user's workspace.
The Solution: Dynamic Detection & Guaranteed Cleanup
Layered Environment Resolution (app/helpers.php): Replaced the rigid fallback logic with dynamic host_uid() and host_gid() helper functions. They query the system in a resilient cascade:
POSIX Extension --> Shell Command ('id -u' / 'id -g') --> Strict Default (1000)This makes the fix completely universal, resolving accurately for any host user ID (1000, 1001, 2000, etc.) at execution runtime.
Guaranteed Ownership Handback (NewCommand.php): Swapped the command chaining operator from short-circuit to sequential
(&& -> ;). File ownership is now cleanly returned to the calling host user even if the internal container installation process crashes midway.Consistency & Codebase Cleanup: Integrated these helpers into InteractsWithDocker.php to align all container operations and resolved a missing method regression in ConfigData.php that was triggering cascading scaffolding crashes.
Status: Local environment binary successfully compiled. All automated test suites are passing cleanly.
Example:
command right now?"
* If User A (UID 1000) runs it, the function returns 1000.
* If User B (UID 1001) runs it, the function returns 1001.
* If User C (UID 2000) runs it, the function returns 2000.
* It first tries the PHP posix extension (most accurate).
* If that fails, it runs the system command id -u, which is the standard Linux way to find the current User ID.
* It only uses 1000 as a "safety net" if both of those fail (which is very unlikely on a standard Linux system).
Yeah, will check on this later once I deployed the ongoing features. This might have been fixed already.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.