`Cannot generate bytecode` / `pkg fails to run "codesign" utility` (even when codesign is present)
What version of pkg are you using?
5.5.2
What version of Node.js are you using?
v14.18.2
What operating system are you using?
macOS 12.2.1 (21D62)
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node14-macos-x64
Describe the Bug
Running npx pkg fails with the following error:
> [email protected]
> Fetching base Node.js binaries to PKG_CACHE_PATH
fetched-v14.18.3-macos-x64 [====================] 100%
/Users/ryan/.pkg-cache/v3.2/fetched-v14.18.3-macos-x64-signed: is already signed
> Error! Cannot generate bytecode
pkg fails to run "codesign" utility. Due to the mandatory signing
requirement of macOS, executables must be signed. Please ensure the
utility is installed and properly configured.
However, codesign is indeed installed and available:
⮑ which codesign
/usr/bin/codesign
⮑ codesign
Usage: codesign -s identity [-fv*] [-o flags] [-r reqs] [-i ident] path ... # sign
codesign -v [-v*] [-R=<req string>|-R <req file path>] path|[+]pid ... # verify
codesign -d [options] path ... # display contents
codesign -h pid ... # display hosting paths
(Related: is the fetched-v14.18.3-macos-x64-signed: is already signed line a red herring?)
Expected Behavior
I expect pkg to successfully run or give me a useful, usable error that I can use to fix the issue.
To Reproduce
Steps to reproduce presented above in the bug description; of course happy to narrow down further if you have any ideas on how I can!
I had the same issue. As a workaround you can go to the source code and add a "-f" flag when they call the codesign utility:
https://github.com/vercel/pkg/blob/b63df87586dfb0a5f56e8698f753846edee4a498/lib/mach-o.ts#L62
I started having this issue when I updated my macos version.
@brianunlam that's a nice workaround, did the trick for me. It's super brittle for obvious reasons, @jesec @leerob any reason not to incorporate this into the codesign call permanently so we can close this issue?
$ sed -e s/--sign/-s/ -i ./node_modules/pkg/lib-es5/mach-o.js did the trick for me, FYI.
cc @jesec
@brianunlam that's a nice workaround, did the trick for me. It's super brittle for obvious reasons, @jesec @leerob any reason not to incorporate this into the
codesigncall permanently so we can close this issue?
Here it's the pr
https://github.com/vercel/pkg/pull/1756
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
The issue isn’t stale. It has PR, even. Auto-closing issues is gross.
@ryanblock The PR #1756 is merged. You can close this Issue
@134130 happy to close this as soon as the fix is released to production. (Maintainers ofc can also close it should they see fit!)
It should be out, yay!