Skip to content

fix: homebrew cask postflight xattr references wrong binary name#2899

Merged
markphelps merged 1 commit intomainfrom
fix/homebrew-cask-postflight-xattr
Apr 1, 2026
Merged

fix: homebrew cask postflight xattr references wrong binary name#2899
markphelps merged 1 commit intomainfrom
fix/homebrew-cask-postflight-xattr

Conversation

@markphelps
Copy link
Copy Markdown
Contributor

Summary

  • Fixes brew install --cask replicate/tap/cog failing with xattr: No such file during postflight
  • Extracts inline cask heredoc into a standalone .github/cog.rb.tmpl template file

Problem

The postflight block runs xattr -dr com.apple.quarantine on #{staged_path}/cog, but the downloaded binary is named cog_Darwin_arm64 (or cog_Darwin_x86_64) in the staged directory. The binary stanza creates a symlink with the target name cog in /opt/homebrew/bin/, but does not rename the file in the staged path.

xattr: No such file: /opt/homebrew/Caskroom/cog/0.17.1/cog
Error: Failure while executing; `/usr/bin/env /usr/bin/xattr -dr com.apple.quarantine /opt/homebrew/Caskroom/cog/0.17.1/cog` exited with 1.

Corresponds to replicate/homebrew-tap#32

Fix

Use Hardware::CPU.arm? to construct the correct binary filename in the postflight block, matching the actual file in the staged directory.

Template extraction

The inline heredoc + sed substitution was fragile and hard to read. The cask is now a standalone template at .github/cog.rb.tmpl with envsubst doing variable substitution:

  • The .rb.tmpl file looks like the actual Ruby cask -- readable, diffable, syntax-highlightable
  • envsubst with an explicit variable list ('${VERSION} ${SHA_ARM} ${SHA_X86}') only substitutes shell placeholders while preserving Ruby #{...} interpolation
  • Workflow now does actions/checkout (sparse) to get the template, then downloads checksums

The postflight block ran xattr on staged_path/cog, but the actual binary
in the staged directory is named cog_Darwin_arm64 or cog_Darwin_x86_64.
The binary stanza only creates a symlink -- it doesn't rename the source.

Fix by constructing the correct filename using Hardware::CPU.arm? in the
postflight block.

Also extract the inline cask heredoc into a standalone .github/cog.rb.tmpl
template file. This makes the cask easier to read, edit, and diff. The
workflow now uses envsubst with an explicit variable list to substitute
only the shell placeholders while preserving Ruby interpolation.
@markphelps markphelps requested a review from a team as a code owner April 1, 2026 13:05
@ask-bonk
Copy link
Copy Markdown

ask-bonk bot commented Apr 1, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR fixes the Homebrew cask postflight xattr command referencing the wrong binary name, and extracts the inline heredoc into a standalone template file.

One issue with indentation consistency in the template:

cat > /tmp/review.json << 'REVIEW'
{
  "event": "COMMENT",
  "body": "This PR correctly fixes the `xattr` command in the Homebrew cask postflight to reference the actual binary filename (`cog_Darwin_arm64` or `cog_Darwin_x86_64`) instead of the non-existent `cog` in the staged path.\n\nOne minor formatting suggestion for better readability in the template.",
  "comments": [
    {
      "path": ".github/cog.rb.tmpl",
      "start_line": 21,
      "line": 26,
      "side": "RIGHT",
      "body": "The indentation is inconsistent here - the `on_intel` block content is at a different level than `on_arm`. For better readability and to match standard Ruby formatting:\n\n```suggestion\n  binary \"cog_Darwin_#{on_intel do\n                         \\\"x86_64\\\"\n                       end\n                       on_arm do\n                         \\\"arm64\\\"\n                       end}\", target: \"cog\"\n```\n\nAlternatively, consider using a more compact form:\n```ruby\n  binary \"cog_Darwin_#{Hardware::CPU.arm? ? \\\"arm64\\\" : \\\"x86_64\\\"}\", target: \"cog\"\n```\n\nThis would be consistent with how the `postflight` block handles the architecture detection."
    }
  ]
}
REVIEW
gh api repos/replicate/cog/pulls/2899/reviews --input /tmp/review.json

github run

@markphelps markphelps added this pull request to the merge queue Apr 1, 2026
Merged via the queue into main with commit 8f142dd Apr 1, 2026
72 of 74 checks passed
@markphelps markphelps deleted the fix/homebrew-cask-postflight-xattr branch April 1, 2026 16:14
markphelps added a commit that referenced this pull request Apr 8, 2026
…icate/cog into mphelps/push-phase-progress

* 'mphelps/push-phase-progress' of https://github.com/replicate/cog: (95 commits)
  feat: add metric name validation (#2911)
  Rename `cog run` to `cog exec` (#2916)
  chore(deps): bump github.com/google/go-containerregistry (#2884)
  fix: replace removed libgl1-mesa-glx in tensorflow integration test (#2914)
  ci: enforce stub freshness in CI, fix existing stub drift (#2912)
  feat: add schema-compare command to test harness (#2891)
  chore(deps): bump uuid from 1.22.0 to 1.23.0 in /crates (#2887)
  chore(deps): bump github.com/hashicorp/go-version from 1.7.0 to 1.9.0 (#2909)
  chore(deps): bump insta from 1.46.3 to 1.47.2 in /crates (#2908)
  fix: support list[X] | None inputs + integration tests for PEP 604 union File/Path coercion (#2882)
  ci: exclude Dependabot PRs from auto-code review (#2910)
  chore(deps): bump actions/checkout from 4 to 6 (#2904)
  chore(deps): bump github.com/testcontainers/testcontainers-go/modules/registry (#2886)
  fix: metrics bugs in coglet prediction server (#2896)
  Bump version to 0.17.2 (#2903)
  fix(coglet): propagate metric scope to async event loop thread (#2902)
  chore: remove unnecessary nolint directive in test (#2803)
  feat(coglet): add Sentry error reporting for infrastructure errors (#2865)
  fix: homebrew cask postflight xattr references wrong binary name (#2899)
  fix: include custom metrics in cog predict --json output (#2897)
  ...
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