Skip to content

!Fix :public_key loading in Mix tasks for macOS signing#16

Merged
dominicletz merged 4 commits into
elixir-desktop:mainfrom
dominicletz:fix/ensure-public-key-for-mix-tasks
Jul 17, 2026
Merged

!Fix :public_key loading in Mix tasks for macOS signing#16
dominicletz merged 4 commits into
elixir-desktop:mainfrom
dominicletz:fix/ensure-public-key-for-mix-tasks

Conversation

@dominicletz

Copy link
Copy Markdown
Contributor

Summary

mix desktop.create_keychain fails on CI with:

** (UndefinedFunctionError) function :public_key.pem_decode/1 is undefined (module :public_key is not available)

#14 replaced Mix.ensure_application!(:public_key) with Application.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/1 fails when packaging/signing on macOS.

Fix

Restore the pattern Elixir itself uses in Mix.Utils (e.g. HTTPS fetch):

  1. Mix.ensure_application!(:public_key) — put :public_key / :crypto / :asn1 on the path and load them
  2. {:ok, _} = Application.ensure_all_started(:public_key) — start them and fail loudly if that fails

Mix.ensure_application!/1 remains a documented public API since Elixir 1.15.

Test plan

  • mix test test/locate_uid_test.exs — generates a self-signed PEM and asserts locate_uid/1 decodes without UndefinedFunctionError
  • Re-run macOS binary CI against a consumer (e.g. ddrive) that depends on this commit

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/package/macos.ex
Comment thread test/locate_uid_test.exs
@dominicletz

Copy link
Copy Markdown
Contributor Author

@cursoragent review the gemini review comments. Update the elixir version in mix.exs to an appropriate recent elixir version.

dominicletz and others added 3 commits July 17, 2026 13:10
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>
@dominicletz
dominicletz merged commit 657fa38 into elixir-desktop:main Jul 17, 2026
2 checks passed
@dominicletz
dominicletz deleted the fix/ensure-public-key-for-mix-tasks branch July 17, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants