Repository navigation
Conversation
The Darwin build links dynamically against pkgs.libiconv, baking the
/nix/store/<hash>-libiconv-*/lib/libiconv.2.dylib path into the binary's
LC_LOAD_DYLIB entry. When the binary is distributed standalone via
push-artifact-ids (how consumers of this Action receive it), that store
path doesn't exist on their machine and dyld aborts with:
Library not loaded: /nix/store/<hash>-libiconv-109.100.2/lib/libiconv.2.dylib
Reason: tried: '...' (no such file)
Rewriting the install_name to /usr/lib/libiconv.2.dylib — which is
always present on macOS — makes the artifact relocatable.
Linux is unaffected because its build already uses +crt-static against
the musl target.
📝 WalkthroughWalkthroughA Darwin-only Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@flake.nix`:
- Around line 112-117: The current loop captures all matching libiconv install
names into a newline-separated variable "linked" and uses word-splitting-prone
command substitution for "bin", causing failures when there are multiple matches
or spaces in paths; change the logic to iterate safely over binaries with find
-print0 and a null-delimited read (reading into "bin"), then for each binary
parse otool -L and iterate over each matching install name with a null-delimited
loop (reading into "linked") and call install_name_tool -change "$linked"
"/usr/lib/libiconv.2.dylib" "$bin" for each match so each install name is
processed independently without word-splitting issues.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| for bin in $(find "$out/bin" -type f); do | ||
| linked=$(otool -L "$bin" | awk '/\/nix\/store\/.*libiconv.*\.dylib/ {print $1}') || true | ||
| if [ -n "$linked" ]; then | ||
| echo "Rewriting $bin: $linked -> /usr/lib/libiconv.2.dylib" | ||
| install_name_tool -change "$linked" "/usr/lib/libiconv.2.dylib" "$bin" | ||
| fi |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
linked=$(
printf '%s\n' \
'/nix/store/aaa-libiconv/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)' \
'/nix/store/bbb-libiconv/lib/libiconv-extra.dylib (compatibility version 1.0.0, current version 1.0.0)' |
awk '/\/nix\/store\/.*libiconv.*\.dylib/ {print $1}'
)
python3 - "$linked" <<'PY'
import sys
arg = sys.argv[1]
assert "\n" in arg, repr(arg)
print("current snippet would pass one newline-containing argument:", repr(arg))
PYRepository: DeterminateSystems/flakehub-push
Length of output: 232
🏁 Script executed:
head -n 120 flake.nix | tail -n 25 | cat -nRepository: DeterminateSystems/flakehub-push
Length of output: 1562
Process each matched install name independently.
If otool emits more than one matching libiconv load command, the linked variable becomes a newline-separated string and install_name_tool -change "$linked" won't match any single install name. Additionally, the find command substitution can word-split binary paths. Loop over each match and binary using null delimiters instead.
Proposed shell hardening
- for bin in $(find "$out/bin" -type f); do
- linked=$(otool -L "$bin" | awk '/\/nix\/store\/.*libiconv.*\.dylib/ {print $1}') || true
- if [ -n "$linked" ]; then
- echo "Rewriting $bin: $linked -> /usr/lib/libiconv.2.dylib"
- install_name_tool -change "$linked" "/usr/lib/libiconv.2.dylib" "$bin"
- fi
- done
+ while IFS= read -r -d "" bin; do
+ while IFS= read -r linked; do
+ if [ -n "$linked" ]; then
+ echo "Rewriting $bin: $linked -> /usr/lib/libiconv.2.dylib"
+ install_name_tool -change "$linked" "/usr/lib/libiconv.2.dylib" "$bin"
+ fi
+ done < <(otool -L "$bin" 2>/dev/null | awk '/\/nix\/store\/.*libiconv.*\.dylib/ {print $1}' || true)
+ done < <(find "$out/bin" -type f -print0)📝 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.
| for bin in $(find "$out/bin" -type f); do | |
| linked=$(otool -L "$bin" | awk '/\/nix\/store\/.*libiconv.*\.dylib/ {print $1}') || true | |
| if [ -n "$linked" ]; then | |
| echo "Rewriting $bin: $linked -> /usr/lib/libiconv.2.dylib" | |
| install_name_tool -change "$linked" "/usr/lib/libiconv.2.dylib" "$bin" | |
| fi | |
| while IFS= read -r -d "" bin; do | |
| while IFS= read -r linked; do | |
| if [ -n "$linked" ]; then | |
| echo "Rewriting $bin: $linked -> /usr/lib/libiconv.2.dylib" | |
| install_name_tool -change "$linked" "/usr/lib/libiconv.2.dylib" "$bin" | |
| fi | |
| done < <(otool -L "$bin" 2>/dev/null | awk '/\/nix\/store\/.*libiconv.*\.dylib/ {print $1}' || true) | |
| done < <(find "$out/bin" -type f -print0) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@flake.nix` around lines 112 - 117, The current loop captures all matching
libiconv install names into a newline-separated variable "linked" and uses
word-splitting-prone command substitution for "bin", causing failures when there
are multiple matches or spaces in paths; change the logic to iterate safely over
binaries with find -print0 and a null-delimited read (reading into "bin"), then
for each binary parse otool -L and iterate over each matching install name with
a null-delimited loop (reading into "linked") and call install_name_tool -change
"$linked" "/usr/lib/libiconv.2.dylib" "$bin" for each match so each install name
is processed independently without word-splitting issues.
Problem
Consumers of this Action on
macos-latestrunners fail with:The Darwin build in
flake.nixlinks dynamically againstpkgs.libiconv, which bakes the/nix/store/<hash>-libiconv-*/lib/libiconv.2.dylibpath into the binary'sLC_LOAD_DYLIBentry. That artifact is then uploaded viapush-artifact-idsand fetched as a standalone binary by action consumers. On their runners the specific store path doesn't exist and dyld aborts on the first invocation.Linux is unaffected because its build already uses
+crt-staticagainst a musl target.Fix
Add a Darwin-only
postInstallthat rewrites any/nix/store/*libiconv*.dylibreferences in the binary's install names to/usr/lib/libiconv.2.dylib, which is always present on macOS. This mirrors the pattern used by e.g. gnosis/gnosis_vpn-client#502 for the same class of bug.Verification
nix flake show --all-systemsevaluates cleanly forx86_64-linux,aarch64-linux, andaarch64-darwin.nixfmt --check flake.nixpasses.nix buildand inspectotool -Lon the result, but the postInstall is a no-op when no matching reference exists, and mirrors the exact pattern proven in the linked gnosis PR.Summary by CodeRabbit