fix: elevate with sudo when installing as a non-root user #6
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/install-dir-permissions"
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?
Fix "Permission denied" when the action installs Nushell on GitHub-hosted runners.
GitHub-hosted runners execute as a non-root user, so
cpof nu and its plugins into /usr/bin fails with Permission denied. The self-hosted Forgejo/Gitea act containers run as root, where the copy succeeds and sudo is frequently not installed, so an unconditionalsudo cpwould break that path instead.The script now detects the situation at runtime: as root it uses no elevation; as a non-root user with sudo on PATH it prefixes the privileged operations (cp into /usr/bin and chsh) with sudo; otherwise it exits with a clear message. One script, both environments.
Tested: sh -n parses clean. Note the existing .forgejo test workflow runs as root and exercises only the no-sudo path; a matching GitHub Actions workflow would cover the sudo path on the environment where this broke (happy to add it as a follow-up).