hraban / mac-app-util

Fix .app programs installed by Nix on Mac
GNU Affero General Public License v3.0
179 stars 6 forks source link

replacing existing signature error #3

Closed joscha closed 5 months ago

joscha commented 6 months ago

I seem to get a .: replacing existing signature per app and the command ends non-zero:

Screenshot 2024-05-28 at 2 59 53 PM

since adding the util. It seems to work as expected, however I'd love to remove the errors.

It seems possibly related to https://stackoverflow.com/questions/56889119/replace-existing-signature-error-when-deploying via plutil: https://github.com/hraban/mac-app-util/blob/b2d3667f3b8d650310e55b38d3c4a5f35949e1f6/main.lisp#L126-L127

hraban commented 5 months ago

Apparently it's osacompile:

$ /usr/bin/osacompile -o "Fooblub.app" -e "do shell script \"open '/bla/FooBlub.app'\""
.: replacing existing signature
$ echo $?
0

It's not really an error, just some pointless diagnostic message. I'm not sure what to do about it or what it even means, but I'm tempted to just leave it. I also can't find much info about it online..

Your non-0 exit is definitely a bigger problem and it seems unrelated to osacompile or that error. I've uploaded a debug build for you; can you retry your nix-darwin switch with --override-input mac-app-util github:hraban/mac-app-util/debug and paste the results here?

hraban commented 5 months ago

(this is assuming you-re using flakes--if not, fetch the debug branch and pin that in your config)

joscha commented 5 months ago

Thanks @hraban!

Output is:

; /usr/bin/osacompile -o "/Users/joscha/Applications/Home Manager Trampolines/iTerm2.app" -e "do shell script \"open '/nix/store/1mc1y61nwzr27wi8a3dwsxbwq5kp4zlk-iterm2-3.4.23/Applications/iTerm2.app/'\""
.: replacing existing signature
; (find "/Users/joscha/Applications/Home Manager Trampolines/iTerm2.app/Contents/Resources/" -name "*.icns" -delete && rsync --include "*.icns" --exclude "*" --recursive /nix/store/1mc1y61nwzr27wi8a3dwsxbwq5kp4zlk-iterm2-3.4.23/Applications/iTerm2.app//Contents/Resources/ "/Users/joscha/Applications/Home Manager Trampolines/iTerm2.app/Contents/Resources/")
; mktemp -d
; (/usr/bin/plutil -convert json -- orig && /usr/bin/plutil -convert json -- bare-wrapper && jq --argjson keys "[\"CFBundleDevelopmentRegion\",\"CFBundleDocumentTypes\",\"CFBundleGetInfoString\",\"CFBundleIconFile\",\"CFBundleIdentifier\",\"CFBundleInfoDictionaryVersion\",\"CFBundleName\",\"CFBundleShortVersionString\",\"CFBundleURLTypes\",\"NSAppleEventsUsageDescription\",\"NSAppleScriptEnabled\",\"NSDesktopFolderUsageDescription\",\"NSDocumentsFolderUsageDescription\",\"NSDownloadsFolderUsageDescription\",\"NSPrincipalClass\",\"NSRemovableVolumesUsageDescription\",\"NSServices\",\"UTExportedTypeDeclarations\"]" "to_entries |[.[]| select(.key as \$item| \$keys | index(\$item) >= 0) ] | from_entries" < orig > filtered && (cat bare-wrapper filtered | jq -s add > final) && /usr/bin/plutil -convert xml1 -- final)
; /usr/bin/osacompile -o "/Users/joscha/Applications/Home Manager Trampolines/Teams.app" -e "do shell script \"open '/nix/store/1zlkp7jzf9pyizp4fbssi1z07xgsbch2-teams-1.6.00.4464/Applications/Teams.app/'\""
.: replacing existing signature
; (find "/Users/joscha/Applications/Home Manager Trampolines/Teams.app/Contents/Resources/" -name "*.icns" -delete && rsync --include "*.icns" --exclude "*" --recursive /nix/store/1zlkp7jzf9pyizp4fbssi1z07xgsbch2-teams-1.6.00.4464/Applications/Teams.app//Contents/Resources/ "/Users/joscha/Applications/Home Manager Trampolines/Teams.app/Contents/Resources/")
; mktemp -d
; (/usr/bin/plutil -convert json -- orig && /usr/bin/plutil -convert json -- bare-wrapper && jq --argjson keys "[\"CFBundleDevelopmentRegion\",\"CFBundleDocumentTypes\",\"CFBundleGetInfoString\",\"CFBundleIconFile\",\"CFBundleIdentifier\",\"CFBundleInfoDictionaryVersion\",\"CFBundleName\",\"CFBundleShortVersionString\",\"CFBundleURLTypes\",\"NSAppleEventsUsageDescription\",\"NSAppleScriptEnabled\",\"NSDesktopFolderUsageDescription\",\"NSDocumentsFolderUsageDescription\",\"NSDownloadsFolderUsageDescription\",\"NSPrincipalClass\",\"NSRemovableVolumesUsageDescription\",\"NSServices\",\"UTExportedTypeDeclarations\"]" "to_entries |[.[]| select(.key as \$item| \$keys | index(\$item) >= 0) ] | from_entries" < orig > filtered && (cat bare-wrapper filtered | jq -s add > final) && /usr/bin/plutil -convert xml1 -- final)
; /usr/bin/osacompile -o "/Users/joscha/Applications/Home Manager Trampolines/Visual Studio Code.app" -e "do shell script \"open '/nix/store/8anlgfshpf5048fpkbxxljd22f6ixxwk-vscode-1.89.1/Applications/Visual Studio Code.app/'\""
.: replacing existing signature
; (find "/Users/joscha/Applications/Home Manager Trampolines/Visual Studio Code.app/Contents/Resources/" -name "*.icns" -delete && rsync --include "*.icns" --exclude "*" --recursive "/nix/store/8anlgfshpf5048fpkbxxljd22f6ixxwk-vscode-1.89.1/Applications/Visual Studio Code.app//Contents/Resources/" "/Users/joscha/Applications/Home Manager Trampolines/Visual Studio Code.app/Contents/Resources/")
; mktemp -d
; (/usr/bin/plutil -convert json -- orig && /usr/bin/plutil -convert json -- bare-wrapper && jq --argjson keys "[\"CFBundleDevelopmentRegion\",\"CFBundleDocumentTypes\",\"CFBundleGetInfoString\",\"CFBundleIconFile\",\"CFBundleIdentifier\",\"CFBundleInfoDictionaryVersion\",\"CFBundleName\",\"CFBundleShortVersionString\",\"CFBundleURLTypes\",\"NSAppleEventsUsageDescription\",\"NSAppleScriptEnabled\",\"NSDesktopFolderUsageDescription\",\"NSDocumentsFolderUsageDescription\",\"NSDownloadsFolderUsageDescription\",\"NSPrincipalClass\",\"NSRemovableVolumesUsageDescription\",\"NSServices\",\"UTExportedTypeDeclarations\"]" "to_entries |[.[]| select(.key as \$item| \$keys | index(\$item) >= 0) ] | from_entries" < orig > filtered && (cat bare-wrapper filtered | jq -s add > final) && /usr/bin/plutil -convert xml1 -- final)
; /usr/bin/osacompile -o "/Users/joscha/Applications/Home Manager Trampolines/Slack.app" -e "do shell script \"open '/nix/store/vy7c18ar0m2nahgzs27i0giifm5jvfh4-slack-4.38.121/Applications/Slack.app/'\""
.: replacing existing signature
; (find "/Users/joscha/Applications/Home Manager Trampolines/Slack.app/Contents/Resources/" -name "*.icns" -delete && rsync --include "*.icns" --exclude "*" --recursive /nix/store/vy7c18ar0m2nahgzs27i0giifm5jvfh4-slack-4.38.121/Applications/Slack.app//Contents/Resources/ "/Users/joscha/Applications/Home Manager Trampolines/Slack.app/Contents/Resources/")
; mktemp -d
; (/usr/bin/plutil -convert json -- orig && /usr/bin/plutil -convert json -- bare-wrapper && jq --argjson keys "[\"CFBundleDevelopmentRegion\",\"CFBundleDocumentTypes\",\"CFBundleGetInfoString\",\"CFBundleIconFile\",\"CFBundleIdentifier\",\"CFBundleInfoDictionaryVersion\",\"CFBundleName\",\"CFBundleShortVersionString\",\"CFBundleURLTypes\",\"NSAppleEventsUsageDescription\",\"NSAppleScriptEnabled\",\"NSDesktopFolderUsageDescription\",\"NSDocumentsFolderUsageDescription\",\"NSDownloadsFolderUsageDescription\",\"NSPrincipalClass\",\"NSRemovableVolumesUsageDescription\",\"NSServices\",\"UTExportedTypeDeclarations\"]" "to_entries |[.[]| select(.key as \$item| \$keys | index(\$item) >= 0) ] | from_entries" < orig > filtered && (cat bare-wrapper filtered | jq -s add > final) && /usr/bin/plutil -convert xml1 -- final)
; (dockutil -L | grep /nix/store | grep persistentApps | cut -f 1)
; dockutil --add "/nix/store/8anlgfshpf5048fpkbxxljd22f6ixxwk-vscode-1.89.1/Applications/Visual Studio Code.app/" --replacing "Visual Studio Code"
adding /nix/store/8anlgfshpf5048fpkbxxljd22f6ixxwk-vscode-1.89.1/Applications/Visual Studio Code.app

and oddly exits zero?!

Maybe your build brings some updated dependencies in here:

• Updated input 'mac-app-util':
    'github:hraban/mac-app-util/b2d3667f3b8d650310e55b38d3c4a5f35949e1f6' (2024-03-10)
  → 'github:hraban/mac-app-util/38865c213447e7ce05730056791ff31109f1903e' (2024-06-10)
• Updated input 'mac-app-util/nixpkgs':
    'github:NixOS/nixpkgs/db339f1706f555794b71aa4eb26a5a240fb6a599' (2024-03-10)
  → 'github:NixOS/nixpkgs/cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9' (2024-06-08)
building the system configuration...
warning: not writing modified lock file of flake 'git+file:///Users/joscha/.config?ref=refs/heads/master&rev=6e95fb7e310a125a2df86c68ac6c219ecdda8d7c':
• Updated input 'mac-app-util':
    'github:hraban/mac-app-util/b2d3667f3b8d650310e55b38d3c4a5f35949e1f6' (2024-03-10)
  → 'github:hraban/mac-app-util/38865c213447e7ce05730056791ff31109f1903e' (2024-06-10)
• Updated input 'mac-app-util/nixpkgs':
    'github:NixOS/nixpkgs/db339f1706f555794b71aa4eb26a5a240fb6a599' (2024-03-10)
  → 'github:NixOS/nixpkgs/cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9' (2024-06-08)

?

Without the override (rerunning the switch after trying your debug build) it is still:

Activating trampolineApps
.: replacing existing signature
.: replacing existing signature
.: replacing existing signature
.: replacing existing signature
adding /nix/store/8anlgfshpf5048fpkbxxljd22f6ixxwk-vscode-1.89.1/Applications/Visual Studio Code.app
Could not kickstart service "com.apple.Dock.agent": 1: Operation not permitted

exiting non-zero.

adding /nix/store/8anlgfshpf5048fpkbxxljd22f6ixxwk-vscode-1.89.1/Applications/Visual Studio Code.app
Could not kickstart service "com.apple.Dock.agent": 1: Operation not permitted

has never shown up before I tried the debug build.

hraban commented 5 months ago

This may be related to the new release of dockutils which I think fixed this bug.

Anyway good stuff!

hraban commented 5 months ago

I'm gonna close this issue, lmk if you need to reopen it

joscha commented 5 months ago

I'm gonna close this issue, lmk if you need to reopen it

it does still seem to happen after I reverted back away from the debug build. What am I doing wrong?

hraban commented 5 months ago

Did you pin the latest update to the master branch? a3873969fc0198b308881cbd9a1863e6ca429f26 ?

joscha commented 5 months ago

Did you pin the latest update to the master branch? a387396 ?

I did now. Thank you!

joscha commented 4 months ago

The issue started reappearing with the latest version:

Activating trampolineApps
.: replacing existing signature
.: replacing existing signature
.: replacing existing signature
.: replacing existing signature
adding /nix/store/aasaj3iwq7mk0jm0d227xvqva5jylyyc-vscode-1.90.2/Applications/Visual Studio Code.app

presumably the VSCode part is causing trouble. Unsure where exactly.

joscha commented 4 months ago

just tried again with 63f269f737cafb2219ba38780c1ecb1dc24bc4a2 after:

• Updated input 'mac-app-util':
    'github:hraban/mac-app-util/1857b26aceaf64c2b6a357eb83cf34139b6365cc' (2024-06-20)
  → 'github:hraban/mac-app-util/63f269f737cafb2219ba38780c1ecb1dc24bc4a2' (2024-07-02)

same thing

hraban commented 4 months ago

"Replacing existing signature" was never a bug to solve in the first place; it's diagnostic output by osacompile which I don't control. The problem was the non-0 exit code, which should now be solved.

See https://github.com/hraban/mac-app-util/issues/3#issuecomment-2157138976

joscha commented 4 months ago

ah, sorry, I was not precise:

___config
hraban commented 4 months ago

Interesting. What command exactly are you running? I can't repro this.

joscha commented 4 months ago

Command is:

./result/sw/bin/darwin-rebuild switch --flake . --fallback

from within my config folder. Trying to see whether anything else could cause this. Thanks for double-checking.

joscha commented 4 months ago

Trying to see whether anything else could cause this.

Found the culprit. A popd > /dev/null 2>&1 with an empty stack. Doesn't print anything, but exits non-zero 🙄 . Thanks for checking on your side, would have never found this without.

hraban commented 4 months ago

🙌

I personally prefer using ( cd somedir ; ... <rest of script here> ) over pushd / popd precisely to avoid this type of syncing problems.