-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(desktop): stage and sign libnode dylib for Homebrew-installed Node #7803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
53958cb
5dbaa81
5d39881
2063737
7eb2aa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,35 @@ stage_local_node() { | |
| cp -f "$node_bin" "$NODE_RESOURCE" | ||
| chmod +x "$NODE_RESOURCE" | ||
| xattr -cr "$NODE_RESOURCE" 2>/dev/null || true | ||
|
|
||
| # Homebrew node is a small stub that dlopen()s libnode.X.dylib via @loader_path. | ||
| # Copy the dylib alongside the binary so it resolves at both validation and runtime. | ||
| local libnode_name | ||
| libnode_name=$(otool -L "$node_bin" 2>/dev/null \ | ||
| | awk 'match($0, /libnode\.[0-9]+\.dylib/) {print substr($0, RSTART, RLENGTH); exit}') | ||
| if [ -n "$libnode_name" ]; then | ||
| local libnode_src="" | ||
| local node_bin_dir | ||
| node_bin_dir="$(dirname "$(realpath "$node_bin")")" | ||
| for candidate in \ | ||
| "$node_bin_dir/../lib/$libnode_name" \ | ||
| "$node_bin_dir/$libnode_name" \ | ||
| "$(brew --prefix 2>/dev/null)/lib/$libnode_name"; do | ||
| if [ -f "$candidate" ]; then | ||
| libnode_src="$(realpath "$candidate")" | ||
| break | ||
| fi | ||
| done | ||
| if [ -z "$libnode_src" ]; then | ||
| echo "ERROR: node requires $libnode_name but it was not found near $node_bin or in Homebrew lib." >&2 | ||
| exit 1 | ||
| fi | ||
| cp -f "$libnode_src" "$(dirname "$NODE_RESOURCE")/$libnode_name" | ||
| chmod u+w "$(dirname "$NODE_RESOURCE")/$libnode_name" | ||
| xattr -cr "$(dirname "$NODE_RESOURCE")/$libnode_name" 2>/dev/null || true | ||
| log "Staged $libnode_name alongside node (Homebrew dynamic build)" | ||
| fi | ||
|
Comment on lines
+138
to
+155
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The PR description says the Homebrew stub references Placing the dylib in the same directory ( |
||
|
|
||
| log "Staged local Node $("$NODE_RESOURCE" --version) from $node_bin" | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(dirname "$NODE_RESOURCE")is evaluated three times in a row. Capturing it in a local variable makes the intent clearer and avoids repeated subshell overhead.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!