From 1533531261751c84a61fe05d55146d6ddbc6cb44 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 4 Mar 2026 10:25:18 +0000 Subject: [PATCH] Fix macOS runner dylib install name for portable bundles Homebrew bakes an absolute path (/opt/homebrew/opt/libkrun/lib/libkrun.1.dylib) into the runner's Mach-O load command. When the runner is extracted from an embedded bundle into a cache directory, dyld fails to find libkrun.1.dylib because the shipped file is named libkrun.dylib. Use install_name_tool to rewrite the load command to @loader_path/libkrun.dylib during build-runner-darwin, then re-codesign since install_name_tool invalidates the signature. Also use cp -f to handle read-only Homebrew dylibs on rebuild. Fixes #14 Co-Authored-By: Claude Opus 4.6 --- Taskfile.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 1110fd5..2d8ad05 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -22,6 +22,8 @@ vars: BUILDER_IMAGE: ghcr.io/stacklok/propolis-builder LIBKRUN_VERSION: sh: grep '^LIBKRUN_VERSION=' versions.env | cut -d= -f2 + LIBKRUN_MAJOR: + sh: grep '^LIBKRUN_VERSION=' versions.env | cut -d= -f2 | sed 's/^v//' | cut -d. -f1 BUILDER_IMAGE_TAG: '{{.LIBKRUN_VERSION}}' # Quick reference: @@ -73,8 +75,16 @@ tasks: platforms: [darwin] cmds: - task: build-dev-darwin - - cp $(brew --prefix libkrun)/lib/libkrun.dylib bin/ - - cp $(brew --prefix libkrunfw)/lib/libkrunfw.dylib bin/ + - cp -f $(brew --prefix libkrun)/lib/libkrun.dylib bin/ + - cp -f $(brew --prefix libkrunfw)/lib/libkrunfw.dylib bin/ + # Rewrite absolute Homebrew install name to @loader_path for portable bundles + - >- + install_name_tool -change + /opt/homebrew/opt/libkrun/lib/libkrun.{{.LIBKRUN_MAJOR}}.dylib + @loader_path/libkrun.dylib + bin/{{.RUNNER_NAME}} + # Re-sign after binary modification (install_name_tool invalidates signature) + - codesign --entitlements assets/entitlements.plist --force -s - bin/{{.RUNNER_NAME}} generates: - bin/{{.RUNNER_NAME}} - bin/libkrun.dylib