fix: homebrew distribution - #128
Conversation
WalkthroughAdds a Homebrew formula for the prebuilt macOS arm64 PdfSign v0.2.0 release, including project metadata, binary installation into Homebrew’s ChangesHomebrew distribution
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Formula/pdf-sign.rb`:
- Around line 4-5: Replace the placeholder sha256 value in the Formula
definition with the actual SHA-256 checksum computed from the exact v0.2.0
pdf-sign-macos-arm64 release asset referenced by url.
- Around line 4-5: Update the formula’s platform handling around the macOS arm64
URL in the top-level formula definition: either add verified platform-specific
artifacts and SHA256 values for Linux, WSL, and Intel macOS, or explicitly
restrict installation to supported macOS arm64 systems using Homebrew platform
guards and an appropriate caveat. Ensure unsupported users cannot install the
incompatible binary.
- Around line 8-10: Update the install method to install the downloaded URL
basename pdf-sign-macos-arm64 and rename it to pdf-sign during installation, so
the executable is exposed under the expected command name.
- Around line 12-14: Update the formula’s test block to invoke the installed
pdf-sign executable through Homebrew’s standard system API instead of the
unsupported test.shell_script method. Preserve the existing --help argument and
test intent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6906aaac-ea97-425c-beb1-9eee577e2324
📒 Files selected for processing (1)
Formula/pdf-sign.rb
| url "https://github.com/0x77dev/pdf-sign/releases/download/v0.2.0/pdf-sign-macos-arm64" | ||
| sha256 "sha256-hash-placeholder" # To be updated on release |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
Replace the placeholder checksum before merging.
Line 5 is not a valid SHA-256 for the release artifact, so Homebrew’s download verification will reject installation. Compute the checksum for the exact v0.2.0 asset and commit it. (docs.brew.sh)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Formula/pdf-sign.rb` around lines 4 - 5, Replace the placeholder sha256 value
in the Formula definition with the actual SHA-256 checksum computed from the
exact v0.2.0 pdf-sign-macos-arm64 release asset referenced by url.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== formula =="
if [ -f Formula/pdf-sign.rb ]; then
cat -n Formula/pdf-sign.rb
else
echo "Formula/pdf-sign.rb not found"
fi
echo
echo "== git status/stat =="
git status --short
git diff -- Formula/pdf-sign.rb | sed -n '1,160p' || true
echo
echo "== Homebrew formula patterns for platform restrictions in repository =="
rg -n 'only_.*platform|on_(macos|linux)|caveats|system \?|not_recommended|platform :|MacOS\.is_arm64|arch == "arm64"|only_arm64|if macos\.arm64|if SystemArchitecture::X86_64' -S --glob '*.rb' | head -200Repository: 0x77dev/pdf-sign
Length of output: 786
🌐 Web query:
Homebrew formula binary installation error unsupported platform download URL linux Windows documentation
💡 Result:
Homebrew is officially supported on Linux and Windows Subsystem for Linux (WSL) 2 [1][2]. It is not supported for native Windows (i.e., outside of WSL) [1][3]. If you are encountering an "unsupported platform" or similar binary installation error, it is likely due to one of the following reasons: 1. Improper Installation Path: Homebrew must be installed in its default, supported prefix to correctly download and utilize precompiled binary packages (known as bottles) [4][5]. The required paths are: - Linux/WSL: /home/linuxbrew/.linuxbrew [6][5] - macOS Intel: /usr/local [6][5] - macOS Apple Silicon: /opt/homebrew [6][5] Installing outside these paths often forces Homebrew to attempt to build from source, which is frequently unsupported or prone to failure [4][7]. 2. Architecture/Emulator Mismatch: Homebrew enforces strict architecture checks [8][7]. For example, attempting to install ARM-based Homebrew in an Intel default prefix (or vice versa) will trigger an error [7][9]. Ensure you are using the correct terminal architecture or that your shell is not being incorrectly translated (e.g., via Rosetta 2 on macOS) [8][9]. 3. WSL 1 Limitations: While Homebrew may function on WSL 1, it is considered a Tier 3 (experimental/unsupported) platform due to known compatibility issues [1][2]. The Homebrew project strongly recommends using WSL 2 [1][2]. To resolve most binary installation errors: - Ensure Homebrew is installed in the correct default prefix for your OS [4][5]. - Verify that your system meets the requirements (e.g., glibc/gcc on Linux) [1][2]. - If you have an unsupported configuration, the recommended solution is to perform a clean, default installation [4][7]. For further troubleshooting, consult the official Homebrew documentation at https://docs.brew.sh/ [5].
Citations:
- 1: https://docs.brew.sh/Homebrew-on-Linux
- 2: https://github.com/Homebrew/brew/blob/master/docs/Homebrew-on-Linux.md
- 3: https://brew.sh/2019/02/02/homebrew-2.0.0/
- 4: https://github.com/Homebrew/brew/blob/e0ac5459b3462852012371da9a0b2e085c3ba226/docs/Installation.md
- 5: https://docs.brew.sh/Installation
- 6: https://brew.sh/
- 7: Error: Cannot install in Homebrew on Intel processor in ARM default prefix (/opt/homebrew)! Homebrew/brew#9130
- 8: Error: Cannot install in Homebrew under Rosetta 2 in ARM default prefix (/opt/homebrew)! Homebrew/brew#10313
- 9: https://stackoverflow.com/questions/64963370/error-cannot-install-in-homebrew-on-arm-processor-in-intel-default-prefix-usr
Restrict or add artifacts for unsupported platforms.
This formula only exposes a macOS arm64 binary, while Homebrew also runs on Linux, WSL, and Intel Macs. Add platform-specific URLs/checksums or reject unsupported platforms with on_linux, only_on :macos, and/or a caveats; otherwise those users can install an executable that will not run on their platform.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Formula/pdf-sign.rb` around lines 4 - 5, Update the formula’s platform
handling around the macOS arm64 URL in the top-level formula definition: either
add verified platform-specific artifacts and SHA256 values for Linux, WSL, and
Intel macOS, or explicitly restrict installation to supported macOS arm64
systems using Homebrew platform guards and an appropriate caveat. Ensure
unsupported users cannot install the incompatible binary.
| def install | ||
| bin.install "pdf-sign" | ||
| end |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Install the filename downloaded by the URL.
The URL’s basename is pdf-sign-macos-arm64, but bin.install "pdf-sign" looks for pdf-sign in the staging directory. Rename during installation:
Proposed fix
- bin.install "pdf-sign"
+ bin.install "pdf-sign-macos-arm64" => "pdf-sign"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def install | |
| bin.install "pdf-sign" | |
| end | |
| def install | |
| bin.install "pdf-sign-macos-arm64" => "pdf-sign" | |
| end |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Formula/pdf-sign.rb` around lines 8 - 10, Update the install method to
install the downloaded URL basename pdf-sign-macos-arm64 and rename it to
pdf-sign during installation, so the executable is exposed under the expected
command name.
| test do | ||
| test.shell_script { "pdf-sign --help" } | ||
| end |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Locate formula:"
fd -a '^(pdf-sign\.rb|.*\.rb)$' . | sed 's#^\./##' | rg 'Formula|pdf-sign|test-shell-script|shell_script' || true
echo
echo "Formula snippet:"
if [ -f Formula/pdf-sign.rb ]; then
cat -n Formula/pdf-sign.rb | sed -n '1,80p'
fi
echo
echo "Search test.shell_script usage in repo:"
rg -n 'test\.shell_script|shell_script \{' . --glob '*.rb' || true
echo
echo "Search installed executable test patterns nearby:"
rg -n "bin/\S+.*--help|system \\\$?\\\$?\\{bin\\}/|test\s*\n\s*\{" . --glob '*.rb' | head -100Repository: 0x77dev/pdf-sign
Length of output: 1102
🌐 Web query:
Homebrew Formula Cookbook example test do system bin foo --help
💡 Result:
In a Homebrew formula, the test do block is used to verify that the installed software functions correctly [1]. While common commands like foo --version or foo --help are often used for basic smoke tests, Homebrew's official documentation considers them weak tests [1][2]. The preferred approach is to perform a test that exercises the application's actual functionality, such as processing an input file or performing a specific operation [1][3]. If you were to include a test using a system command (often preferred over bare backticks for better error handling and output separation), the modern syntax is to separate the command and its arguments as individual strings [4]: test do system bin/"foo", "--help" end Key considerations for writing tests in Homebrew: 1. Test Environment: The test do block automatically creates a temporary, isolated directory [1]. The environment variable HOME is set to this temporary directory, ensuring the test does not interact with your actual home directory [1]. 2. System Commands: Using system "cmd", "arg1", "arg2" is the recommended way to invoke executables [4]. This avoids shell injection issues and correctly handles arguments with spaces [4]. 3. Assertions: To verify output, you can use shell_output to capture the command's standard output [1]: assert_match "Usage:", shell_output("#{bin}/foo --help") 4. Best Practices: Aim for tests that do not require user input and verify real functionality, such as creating a small test file, running the tool against it, and checking the resulting output [1][5][6]. While a --help test is better than no test at all, reviewers and maintainers generally prefer tests that confirm the software is fully operational [1][3].
Citations:
- 1: https://docs.brew.sh/Formula-Cookbook
- 2: https://github.com/Homebrew/brew/blob/1.3.6/docs/Formula-Cookbook.md
- 3: https://docs.brew.sh/Homebrew-homebrew-core-Maintainer-Guide
- 4: style: separate shell commands Homebrew/homebrew-core#57064
- 5: https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/makeself.rb
- 6: https://github.com/Homebrew/homebrew-core/blob/master/Formula/f/fcp.rb
🌐 Web query:
Homebrew FormulaDSL shell_script test.shell_script
💡 Result:
There is no specialized shell_script method within the Homebrew Formula DSL for defining tests. Instead, to execute shell commands within a formula's test block, you use standard Ruby system command execution methods, primarily shell_output or system [1][2][3]. The test block, defined as test do ... end within a Homebrew Formula, provides an environment where you can verify the installed software's functionality [1][2]. Because it is a standard Ruby block, you have access to various helper methods provided by Homebrew [2][3]: 1. system: Executes a command. It raises an error if the command fails (returns a non-zero exit status). 2. shell_output: Executes a command and returns its standard output. It also raises an error if the command fails, making it ideal for checking the output of commands like --version or specific subcommands. 3. testpath: A reference to a temporary directory created automatically for the test [1][4][5]. Homebrew sets the HOME environment variable to this path during the test, ensuring tests do not interfere with your actual user environment [1]. Example of a typical test block: test do # Write a test file or run a command assert_match "expected output", shell_output("#{bin}/my_executable --version") system "#{bin}/my_executable", "arg1", "arg2" end If you are looking for functionality related to generating shell completions, Homebrew provides the generate_completions_from_executable method, which is distinct from writing general-purpose shell tests [2][6].
Citations:
- 1: https://github.com/Homebrew/brew/blob/1.3.6/docs/Formula-Cookbook.md
- 2: https://docs.brew.sh/rubydoc/Formula.html
- 3: https://docs.brew.sh/Formula-Cookbook
- 4: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/formula.rb
- 5: https://github.com/Homebrew/brew/blob/cbc2b248/Library/Homebrew/formula.rb
- 6: https://github.com/Homebrew/brew/blob/master/docs/Cask-Cookbook.md
🌐 Web query:
"test.shell_script" "Homebrew"
💡 Result:
In the context of Homebrew, there is no specific command or DSL element named test.shell_script [1][2]. If you are looking to execute shell commands within a Homebrew formula during the test phase, you use the standard Ruby system/command execution methods provided within the test do block [2][3]. The recommended approach is to use methods like shell_output to run shell commands and assert their output [4][2]. Common patterns inside a formula's test do block include: 1. Using shell_output: This runs a command and returns the output, which you can then check with assertions like assert_match or assert_equal [4][2]. test do assert_match "expected output", shell_output("#{bin}/program --version") end 2. Using system: This executes a command and expects it to succeed (exit with 0). If the command fails, the test will fail [4][2]. test do system "#{bin}/program", "arg1", "arg2" end If you are referring to Homebrew's internal development tooling, there are files such as Library/Homebrew/test/utils/shell_spec.rb used for testing Homebrew's own utilities, but these are not part of the formula DSL available to users [5]. Additionally, Homebrew allows for external commands, which can be implemented as shell scripts, but these follow a naming convention (e.g., brew-extcmd) and are distinct from formula test blocks [6].
Citations:
- 1: https://docs.brew.sh/rubydoc/Homebrew/DevCmd/Test.html
- 2: https://docs.brew.sh/Formula-Cookbook
- 3: https://github.com/Homebrew/brew/blob/1.3.6/docs/Formula-Cookbook.md
- 4: https://github.com/Homebrew/homebrew-core/blob/c81ef94b3ec4d34611c251fed1974d66170e35c5/Formula/m/make.rb
- 5: https://github.com/Homebrew/brew/blob/cbc2b248/Library/Homebrew/test/utils/shell_spec.rb
- 6: https://docs.brew.sh/External-Commands
Use the standard Homebrew test command API.
test.shell_script is not part of the formula test DSL, so this test is likely to raise NoMethodError. Call the installed executable with system, as Homebrew examples show.
Proposed fix
test do
- test.shell_script { "pdf-sign --help" }
+ system "#{bin}/pdf-sign", "--help"
end📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test do | |
| test.shell_script { "pdf-sign --help" } | |
| end | |
| test do | |
| system "#{bin}/pdf-sign", "--help" | |
| end |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Formula/pdf-sign.rb` around lines 12 - 14, Update the formula’s test block to
invoke the installed pdf-sign executable through Homebrew’s standard system API
instead of the unsupported test.shell_script method. Preserve the existing
--help argument and test intent.
Closes #11
Summary by CodeRabbit
pdf-signcommand-line tool on Apple Silicon Macs.