Skip to content

ubicloud: pack (and so sync/run) fails on macOS bsdtar #3680

Closed

Description

@yolo-jared

What happened

On macOS, gstack-ubi pack exits 1, so sync (and every run/verify that syncs) fails:

tar: a: Cannot stat: No such file or directory
tar: -zf: Cannot stat: No such file or directory
tar: -: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors.

Because -z and -f were read as file names, what it writes to stdout is an uncompressed tar holding only .git. The VM's tar -xzf - (in cmd_unpack) rejects that stream, so nothing is extracted; for run, the VM has already been created by then. Extracted locally, the partial archive is a checkout whose tracked files all show as deleted. The workaround is GNU tar first on PATH as tar (for example /opt/homebrew/bin/gtar through a shim directory).

Cause

cmd_pack L688:

| tar --null -T - -c -C "$tmp" .git -zf -

This depends on GNU tar in two separate ways, so moving the flags alone does not fix it on macOS's bsdtar (3.5.3, libarchive 3.7.4):

  1. -zf - comes after the positional .git. GNU tar accepts options there; bsdtar stops option parsing at the first operand and treats -zf and - as file names.
  2. The -T - names are relative to the work tree, while .git comes from $tmp. GNU tar applies -C in argument order, so the -T names resolve before the -C "$tmp". bsdtar resolves the -T names after the -C, against $tmp, so they are not found. Every single-invocation ordering tried fails on one tar or the other:
Invocation (cwd = work tree, stdin = file list) bsdtar 3.5.3 GNU tar 1.35
as written: --null -T - -c -C T .git -zf - fails works
-czf - --null -T - -C T .git fails: names not found works
-czf - -C SRC --null -T - -C T .git fails: names not found works
-czf - -C T .git --null -T - fails: --null, -T read as names fails
two passes: -cf T/files.tar then -rf T/files.tar -C T .git, then gzip -c works works

CI does not see this (free-tests is green on 047dad78) because test/ubicloud-runner.test.ts (whose pack ships a linked worktree… test covers it) is not in the macos-named-regressions list.

Steps to reproduce

On macOS with the system tar first on PATH, from a gstack checkout at 047dad78 (no Ubicloud account or API key needed):

runner=$PWD/scripts/ubicloud/ubi-runner.sh
d=$(mktemp -d) && cd "$d"
git init -q repo && cd repo && echo a > a && git add a \
  && git -c user.name=t -c user.email=t@t commit -qm one
PATH=/usr/bin:/bin:/usr/sbin:/sbin bash "$runner" pack . > ../pack.tgz; echo "exit=$?"
/usr/bin/tar -tf ../pack.tgz | grep -v '^\.git/.'

Expected: exit 0, and the listing contains a and .git/. Actual: the errors above, exit 1, and the listing is only .git/.

Proposed fix

Build the archive in two passes inside $tmp, which both tars accept:

--- a/scripts/ubicloud/ubi-runner.sh
+++ b/scripts/ubicloud/ubi-runner.sh
@@ -686,5 +686,7 @@
             if [ -e "$f" ] || [ -L "$f" ]; then printf '%s\0' "$f"; fi
           done \
-        | tar --null -T - -c -C "$tmp" .git -zf -
+        | tar --null -T - -cf "$tmp/files.tar"
+      tar -rf "$tmp/files.tar" -C "$tmp" .git
+      gzip -c "$tmp/files.tar"
     )
     rm -rf "$tmp"; trap - EXIT

Verified on macOS with bsdtar 3.5.3 and GNU tar 1.35, under bash 3.2.57: the linked-worktree case from the existing test gives feat ?? .gitignore ?? u 2 exactly as the test expects (the current line gives exit 1 there); a plain checkout with a staged file, a deleted tracked file, an untracked file, a symlink and a file name with a space extracts with the same git status as the current code produces under GNU tar; an empty file list also works, and files.tar is not shipped. The cost is one uncompressed copy of the snapshot written to $tmp before gzip.

The alternative is to require GNU tar (command -v gtar, else a clear die), which is a smaller diff but adds a dependency on macOS. Either way, adding test/ubicloud-runner.test.ts to macos-named-regressions would have caught this one and the usage awk issue, #3679 (the whole file has not been run on macOS here, so it may surface more).

Readiness report

Hit on the 1.91.333.0 install below; the repro above is against main at 047dad78 (1.91.357.0), where the line is unchanged. Home paths are shortened to ~, and the paths of local CLAUDE.md files are removed from the last check line.

gstack doctor
gstack doctor 1.91.333.0
ok              install root    ~/.claude/skills/gstack: claude global current (1.91.333.0), codex global current (1.91.333.0)
ok              rescue refs     none in ~/.claude/skills/gstack
ok              state root      ~/.gstack durable=yes (selected by default)
ok              bun             1.4.4 at /opt/homebrew/bin/bun (floor 1.3.3, tested 1.4.2)
ok              hooks           9 hook(s) parse
ok              codex           codex-cli 0.163.0; self-locate ok; model gpt-6.1-sol (source: ~/.codex/config.toml model)
ok              codex probe     cached MODEL_OK, 18m ago (not re-run; --live probes now)
not configured  artifacts sync  off; cross-machine artifacts sync is unavailable
ok              browse bundle   browse/dist built
ok              binaries        find-browse, design, pdf, gstack-global-discover launch (4 of 4)
ok              cso             native helper 1.91.333.0 (11c17d466af3)
ok              claude code     2.1.303 (Claude Code) at ~/.local/bin/claude
ok              session journal largest of 2: 1.6 MiB
ok              guard log       816 decisions (61 denied)
ok              CLAUDE.md       no gstack section lists skills
14 ok, 0 warn, 1 not configured, 0 fail

Environment

  • Host: Claude Code 2.1.303
  • OS: macOS 26.6.2 (25G83), arm64; /usr/bin/tar bsdtar 3.5.3 (libarchive 3.7.4); /bin/bash 3.2.57
  • gstack: hit on 1.91.333.0, reproduced on main 047dad78 (1.91.357.0)

Activity

  1. added
    S2
    on Oct 31, 2026
  2. capy-ai commented on Nov 2, 2026

    @capy-ai
    Contributor

    Fixed in #3746, merged to main as 74836e4 and released in v1.92.41.0. pack now builds its archive in two tar passes plus gzip, which both macOS bsdtar and GNU tar accept, and sets COPYFILE_DISABLE=1 so Apple's tar adds no ._* files. sync and run work on macOS again. test/regression-issue3680-ubicloud-bsd-userland.test.ts covers it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    S2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions