Skip to content

Cerrar el último hueco del instalador: la rama de sudo - #16

Merged
borjaperfra merged 2 commits into
mainfrom
ci/sudo-path
Sep 14, 2026
Merged

borjaperfra merged 2 commits into
mainfrom
ci/sudo-path

Conversation

@borjaperfra

Copy link
Copy Markdown
Contributor

The one thing in scripts/install.sh still taken on faith.

The installer job put the binary in the runner's temp, which is writable — so install_bin always took its first branch and the sudo fallback was never executed. "It installs fine" said nothing about the path a member hits when /usr/local/bin needs root, which is the common case on a real machine.

Two steps added, on both platforms:

  • The default path, with no INSTALL_DIR: exactly what the one-liner on nan.builders runs, then command -v nan and nan --version.
  • The forced fallback: a root-owned /opt/nan-sudo-test, so install -d fails as the runner user and the sudo branch has to fire. It then asserts the output actually contains retrying with sudo — without that check the step would pass by never taking the branch, which is precisely the failure mode it exists to catch — and runs the binary from where sudo put it.

borjaperfra and others added 2 commits September 14, 2026 15:16
The one thing in scripts/install.sh still taken on faith. The installer job put
the binary in the runner's temp, which is writable, so install_bin always took
its first branch and the sudo fallback was never executed. "It installs fine"
said nothing about the path a member hits when /usr/local/bin needs root, which
is the common case on a real machine.

Two steps, on both platforms. The default path with no INSTALL_DIR, which is
exactly what the one-liner on nan.builders runs. And a root-owned directory, so
`install -d` fails as the runner user and the fallback has to fire.

That second one asserts the output actually contains "retrying with sudo":
without it the step would pass by never taking the branch, which is precisely
the failure mode it exists to catch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Found by the new macOS job, the first time it ran, which is the whole argument
for having added it.

`version="$(get_latest_version)"` runs under `set -euo pipefail`. When the
GitHub API is rate limited there is no `tag_name` in the answer, so `grep`
exits 1, `pipefail` propagates it, and `set -e` kills the script at that line -
one before `require_version`, which is where the explanation lives. The message
written this morning to replace a confusing 404 had never once been printed.

What a member actually saw on a shared IP:

    ‣ fetching latest release...
    <exit 1>

The pipeline ends in `|| true` now, and so does the call, because whether an
empty answer is fatal is the caller's decision and not the pipeline's.

Two more things while here. The lookup sends GITHUB_TOKEN or GH_TOKEN when one
is in the environment: the unauthenticated API allows 60 requests an hour per
IP, and anyone behind a shared address - an office, a CI runner, a tethered
phone - can be on the wrong side of that through no fault of their own. And
REPO is overridable, so a fork can install its own build and so this failure
path can be exercised against a repo that is not there, which is what CI now
does on both platforms.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@borjaperfra
borjaperfra merged commit dd47e15 into main Sep 14, 2026
4 checks passed
@borjaperfra
borjaperfra deleted the ci/sudo-path branch September 14, 2026 13:21
This was referenced Sep 14, 2026
borjaperfra added a commit to helmcode/nan that referenced this pull request Sep 14, 2026
The bash installer's rate-limit message was unreachable: the lookup runs under
`set -euo pipefail`, so a grep finding no tag_name killed the script one line
before the explanation. Anyone behind a shared IP got `fetching latest
release...` and a bare exit. It also sends a token now when one is in the
environment. helmcode/nan-cli#16.

Co-authored-by: borjaperfra <borjaperfra@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants