Skip to content

Commit ea4dab6

Browse files
tannevaledclaude
andcommitted
ci: emit diagnostic ::warning:: annotations from sudo-install
The positive cache check landed but is still failing on the runner: "no new files under \$HOME/.pkgx". To diagnose without log access I need to surface the relevant state via the annotations API. Add four warnings that capture, on every run: - which pkgx the sudo session resolves (the path get_pkgx() returns) - what new files appeared under /root/.pkgx (shebang's deno cache plus any cache the inner pkgx made there) - what new files appeared under \$HOME/.pkgx (the privilege-drop target) - the first 500 bytes of pkgm.ts's stderr, captured with PKGM_DEBUG=1 so the "is not reachable as <user>" fallback diagnostic surfaces To be reverted once the failure mode is identified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1c8cda3 commit ea4dab6

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,38 @@ jobs:
123123

124124
- name: sudo install drops privileges and overrides HOME
125125
run: |
126-
set -eux
126+
set -ux
127127
# marker to scope checks to files created by this install
128128
touch /tmp/pkgm-sudo-marker
129-
sudo ./pkgm.ts i hyperfine
129+
# Run pkgm with PKGM_DEBUG so the "is not reachable as $USER"
130+
# diagnostic surfaces when pkgx_reachable_as falls through; we
131+
# tee stderr so the diagnostic is visible in the job log as well
132+
# as captured for the warning emission below.
133+
sudo PKGM_DEBUG=1 ./pkgm.ts i hyperfine 2> >(tee /tmp/pkgm-sudo.stderr >&2)
134+
rc=$?
135+
set -e
136+
test $rc -eq 0
130137
test -x /usr/local/bin/hyperfine
131138
139+
# Surface enough state as ::warning:: annotations to diagnose
140+
# which branch query_pkgx() took. Failure cases:
141+
# - "pkgx_reachable_as returned undefined" → privilege drop
142+
# skipped → pkgx runs as root with HOME=/root → cache lands
143+
# under /root/.pkgx, none under $HOME/.pkgx.
144+
# - "user_home() failed" → reachable_as falls through to its
145+
# /home/<user>/ rejection regex.
146+
echo "::warning::diag pkgx-via-sudo: $(sudo command -v pkgx 2>&1 || echo none)"
147+
echo "::warning::diag root-new-files: $(sudo find /root/.pkgx -newer /tmp/pkgm-sudo-marker -print 2>/dev/null | head -8 | tr '\n' '|' || echo none)"
148+
echo "::warning::diag user-new-files: $(sudo find $HOME/.pkgx -newer /tmp/pkgm-sudo-marker -print 2>/dev/null | head -8 | tr '\n' '|' || echo none)"
149+
echo "::warning::diag pkgm-stderr: $(tr '\n' '|' < /tmp/pkgm-sudo.stderr | head -c 500 || echo none)"
150+
132151
# HOME override + privilege drop are both validated via the pkg
133152
# cache under $HOME/.pkgx. We deliberately do NOT assert that
134153
# /root/.pkgx is empty: the shebang's `pkgx --quiet deno^2.1 run …`
135154
# runs as root before any pkgm.ts code executes, and that outer
136155
# pkgx caches under $HOME/.pkgx which resolves to /root/.pkgx
137156
# under sudo. That cache is unavoidable and unrelated to whether
138157
# pkgm's *inner* pkgx call dropped privileges.
139-
#
140-
# If pkgm's inner pkgx call dropped privileges and pointed HOME at
141-
# the invoking user, the pkg cache lands under $HOME/.pkgx and is
142-
# owned by the invoking user. If either step failed, the cache
143-
# would be missing here or contain root-owned files.
144158
145159
new_files=$(sudo find "$HOME/.pkgx" -newer /tmp/pkgm-sudo-marker -type f -print 2>/dev/null | head -1 || true)
146160
if [ -z "$new_files" ]; then

0 commit comments

Comments
 (0)