Fix app dev --use-localhost aborting instead of prompting to generate the localhost certificate - #8408
Merged
Conversation
`generateCertificate()` treats `forceInstall` as tri-state and only reaches the "generate it now?" prompt when the value is nullish. The command was collapsing an unpassed `--install-mkcert` into an explicit `false`, so on any app without `.shopify/localhost.pem` the prompt was skipped and `app dev --use-localhost` aborted immediately. Both halves landed in #7632 and first shipped in 4.6.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
/snapit |
Contributor
|
🫰✨ Thanks @craigmichaelmartin! Your snapshot has been published to npm. Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260826150008Caution After installing, validate the version by running |
shauns
approved these changes
Aug 27, 2026
gonzaloriestra
approved these changes
Aug 27, 2026
gonzaloriestra
left a comment
Contributor
There was a problem hiding this comment.
Oops, this was my fault. Working great now, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
shopify app dev --use-localhostaborts immediately on any app that doesn't already have a localhost certificate:The
--use-localhostrequires a certificate forlocalhost. Generate it now? prompt is never shown, so there's no way to get the certificate generated without also passing--install-mkcert. Reproduces on a brand newshopify app initapp.Regression: last good is 4.5.2, first broken is 4.6.0, still broken on
main.generateCertificate()treatsforceInstallas tri-state and only falls through to the prompt when it's nullish —utilities/mkcert.ts:But the command collapsed "flag not passed" into an explicit
false—commands/app/dev.ts:falseisn't nullish, so??never evaluated the prompt and the abort was thrown on every run where the certificate didn't already exist. The flag has noallowNo, sofalsecould only ever come from that default.Both halves came in with #7632:
forceInstall ?? prompt()in ea16242, and the?? falsein the follow-up fb770af — that commit correctly droppeddefault: falsefrom the flag (it was makingdependsOn: ['use-localhost']fire on every invocation) but re-added the same collapse at the call site. First released in 4.6.0.WHAT is this pull request doing?
Lets the flag stay
undefinedwhen it isn't passed, sogenerateCertificate()reaches the prompt again:DevOptions.installMkcertis alreadyboolean | undefined, so nothing else in the chain (commands/app/dev.ts→services/dev.ts→setupNetworkingOptions→generateCertificate) needs to change. A comment at the call site records why there's no default, since the collapse has been reintroduced once already.Tests: the existing expectation encoded the broken value (
installMkcert: false) and now assertsundefined; two tests are added for the--use-localhostpaths with and without--install-mkcert. Both new assertions fail againstmainand pass with the fix.Behaviour that is deliberately unchanged:
--install-mkcert/SHOPIFY_FLAG_INSTALL_MKCERT=1still skips the prompt and installs.SHOPIFY_FLAG_INSTALL_MKCERT=0still resolves to a realfalsethrough oclif'sisTruthy, so a non-interactive decline remains possible without addingallowNo.Failed to prompterror fromthrowInNonTTY, which names the flag to pass.dependsOn: ['use-localhost']is untouched — the??was applied after parsing and never affected oclif validation.No flag definitions or command signatures changed, so no manifest, README, or docs regeneration is needed.
How to test your changes?
Before: aborts with
Localhost certificate and key are required at ....After: prompts
--use-localhost requires a certificate for localhost. Generate it now?, and generating produces.shopify/localhost.pem. Declining still aborts with the same message.Workaround for anyone hitting this on 4.6.0–4.7.0:
shopify app dev --use-localhost --install-mkcertonce, then plain--use-localhostworks.Locally: full
type-checkandlintpass across all packages;dev.test.tsandmkcert.test.tspass. The pre-existinginit.test.ts/config/link.test.ts/config/validate.test.tsfailures on this branch reproduce unchanged onmainand are unrelated.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add🤖 Generated with Claude Code