!Fix :public_key loading in Mix tasks for macOS signing#16
Conversation
Application.ensure_all_started(:public_key) alone does not put OTP libs on the Mix task code path, and ignoring its return left :public_key.pem_decode/1 undefined on CI. Use Mix.ensure_application!/1 then assert ensure_all_started succeeds, matching Elixir's own Mix.Utils pattern.
There was a problem hiding this comment.
Code Review
This pull request ensures that the :public_key application is properly loaded and started in Mix task contexts by introducing a helper function ensure_public_key!/0 and adds a corresponding test suite. The review feedback highlights two critical issues: first, Mix.ensure_application!/1 is only available in Elixir 1.15+, which breaks compatibility with older supported Elixir versions, and should be conditionally invoked; second, the test macro does not natively support an after block, so the cleanup code is silently ignored and must be wrapped in a try ... after block.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@cursoragent review the gemini review comments. Update the elixir version in mix.exs to an appropriate recent elixir version. |
Mix.ensure_application!/1 needs 1.15+, and ExUnit ignores after on the test macro so wrap cleanup in try/after. Co-authored-by: Cursor <cursoragent@cursor.com>
Otherwise a cache hit for OTP alone leaves an older Elixir installed and mix fails after bumping ELIXIR_VERSION. Co-authored-by: Cursor <cursoragent@cursor.com>
create_keychain ci never hits locate_uid, so the PEM decode fix was untested on CI; stop :public_key first so the helper must re-start it. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
mix desktop.create_keychainfails on CI with:#14 replaced
Mix.ensure_application!(:public_key)withApplication.ensure_all_started(:public_key)and ignored the return value. In Mix task context that is not enough: OTP libs are not on the code path the way they are in a started release, so:public_key.pem_decode/1fails when packaging/signing on macOS.Fix
Restore the pattern Elixir itself uses in
Mix.Utils(e.g. HTTPS fetch):Mix.ensure_application!(:public_key)— put:public_key/:crypto/:asn1on the path and load them{:ok, _} = Application.ensure_all_started(:public_key)— start them and fail loudly if that failsMix.ensure_application!/1remains a documented public API since Elixir 1.15.Test plan
mix test test/locate_uid_test.exs— generates a self-signed PEM and assertslocate_uid/1decodes withoutUndefinedFunctionError