Skip to content

fix: authenticate token-based dependency pulls via netrc#78

Merged
td-famedly merged 2 commits into
mainfrom
fix/use-netrc-for-token-auth
Jun 10, 2026
Merged

fix: authenticate token-based dependency pulls via netrc#78
td-famedly merged 2 commits into
mainfrom
fix/use-netrc-for-token-auth

Conversation

@nikzen

@nikzen nikzen commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • build_ios on famedly/app#7173 hangs forever during Xcode SPM dependency resolution whenever the token-based auth path is active — regardless of whether the insteadOf rewrites are global (fix: use git config --add for token insteadOf rewrites #76) or scoped to the famedly org (fix: scope token insteadOf rewrites to the famedly org #77).
  • Root cause is a well-known Xcode/SPM behavior: since Xcode 13.3, SPM asks the macOS keychain for HTTPS credentials — even for public packages and on changing packages each run. On a headless CI runner the keychain prompt can never be answered → infinite hang (Swift Package Manager hangs on xcodebuild actions/runner-images#6233, #13175). The SSH path never hit this because all fetches were rewritten to SSH.
  • Documented fix from the Swift forums / runner-images issues: provide the credentials via ~/.netrc. Both git (HTTPS clones for pub get) and xcodebuild/SPM read it, and no keychain records are created.
  • The remaining insteadOf rewrites only map ssh-style URLs to HTTPS and contain no credentials — the same class of rewrite the proven SSH path uses.

Verification

Verified locally with an isolated $HOME (own .netrc, own gitconfig, no credential helper, SSH disabled):

  • https://github.com/famedly/famedly-design.git resolves via netrc, without any token in git URLs ✓
  • git@github.com:famedly/famedly-design.git is rewritten to HTTPS and resolves via netrc ✓
  • Public repos clone anonymously, untouched ✓
  • The resulting ~/.gitconfig contains no credentials ✓

Made with Cursor

nikzen added 2 commits June 10, 2026 10:39
Embedding the token in git insteadOf URLs makes Xcode's Swift Package
Manager hang forever during dependency resolution on macOS runners:
SPM asks the keychain for HTTPS credentials (even for public packages)
and the headless keychain prompt can never be answered, see
actions/runner-images#6233

A ~/.netrc file is the documented way to authenticate both git HTTPS
clones (pub get) and xcodebuild/SPM on CI without touching the
keychain. The remaining insteadOf rewrites only map ssh-style URLs to
HTTPS and contain no credentials.
xcodebuild's own SCM consults the macOS keychain for HTTPS credentials
even for public packages and hangs headless runners. Forcing the
SwiftPM builtin SCM (system git) makes package resolution honor
gitconfig and ~/.netrc like every other git operation. This is the
defaults equivalent of `xcodebuild -scmProvider system`, required
because `flutter build ipa` invokes xcodebuild internally and cannot
forward the flag.

@td-famedly td-famedly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks sane~

@td-famedly
td-famedly merged commit 566698b into main Jun 10, 2026
1 check passed
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