fix: elevate with sudo when installing as a non-root user #6

Merged
David merged 2 commits from fix/install-dir-permissions into main 2026-06-14 01:45:01 +02:00
Owner

Fix "Permission denied" when the action installs Nushell on GitHub-hosted runners.

GitHub-hosted runners execute as a non-root user, so cp of 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 unconditional sudo cp would 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).

Fix "Permission denied" when the action installs Nushell on GitHub-hosted runners. GitHub-hosted runners execute as a non-root user, so `cp` of 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 unconditional `sudo cp` would 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).
fix: elevate with sudo when installing as a non-root user
All checks were successful
Test / Install Nushell 0.101.0 (push) Successful in 3s
Test / Install Nushell 0.100.0 (push) Successful in 4s
Test / Install Nushell latest (push) Successful in 5s
Test / Install Nushell latest (pull_request) Successful in 5s
Test / Install Nushell 0.101.0 (pull_request) Successful in 5s
Test / Install Nushell 0.100.0 (pull_request) Successful in 3s
63e40b5feb
Copying nu and its plugins into /usr/bin failed with "Permission denied" on GitHub-hosted runners, which run as a non-root user. Self-hosted Forgejo/Gitea act containers run as root, where the copy succeeds and sudo is often not installed, so an unconditional sudo would break that path instead.

Detect the case at runtime: when already root use no elevation, when non-root with sudo available prefix the cp and chsh calls with sudo, and otherwise fail with a clear message. The same script now works on both GitHub runners and root containers.
test: add GitHub Actions workflow to cover the non-root install path
All checks were successful
Test / Install Nushell 0.101.0 (pull_request) Successful in 3s
Test / Install Nushell 0.101.0 (push) Successful in 4s
Test / Install Nushell 0.100.0 (push) Successful in 5s
Test / Install Nushell 0.100.0 (pull_request) Successful in 5s
Test / Install Nushell latest (pull_request) Successful in 5s
Test / Install Nushell latest (push) Successful in 7s
3c53dc4edf
The .forgejo test workflow runs as root, so it never exercises the sudo elevation added for non-root installs and could not have caught the /usr/bin permission failure on GitHub-hosted runners. Add a GitHub Actions workflow mirroring the Forgejo one (same version matrix and assertions) but on ubuntu-latest, which runs as the non-root runner user, so the sudo path is tested on the environment where it broke.
David merged commit 5a43b584ed into main 2026-06-14 01:45:01 +02:00
David deleted branch fix/install-dir-permissions 2026-06-14 01:45:01 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pandoras-box/action-install-nushell!6
No description provided.