Skip to content

Commit b07b731

Browse files
committed
fix(setup): honour required when the docker app fails to launch
db.ts and redis.ts call ensureDocker(false) and branch on the boolean to offer an external Postgres or Redis instead. Throwing past that aborts the whole wizard when a working non-Docker path was on the table, so every post-confirm failure now warns and returns false unless Docker is required. That covers the 90s-timeout throw too, which ignored `required` before this branch existed — leaving it as the one path that still aborts would make the flag mean two different things in one function. Also name DOCKER_CONTEXT in the stale-selection hint. It overrides the config context, so `docker context use` alone leaves the CLI pointed at OrbStack and the next run fails identically.
1 parent ce25e1d commit b07b731

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

scripts/setup/docker.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ function startDockerApp({ app, explicit }: DockerChoice): DockerApp | null {
8787
return openApp(other) ? other : null
8888
}
8989

90+
/**
91+
* A launch that failed after the user opted into it. Callers passing
92+
* required=false have a non-Docker path to offer, so the reason is worth
93+
* surfacing but must not abort the wizard.
94+
*/
95+
function launchFailed(required: boolean, message: string, hints: string[]): boolean {
96+
if (required) throw new SetupError(message, hints)
97+
p.log.warn([message, ...hints].join('\n'))
98+
return false
99+
}
100+
90101
/**
91102
* Returns whether the Docker daemon is available, offering to launch the
92103
* installed docker app (macOS) when it's stopped. Never installs anything.
@@ -126,21 +137,20 @@ export async function ensureDocker(required: boolean): Promise<boolean> {
126137

127138
const app = startDockerApp(choice)
128139
if (!app) {
129-
if (choice.explicit) {
130-
throw new SetupError('The docker CLI is pointed at OrbStack, which is not installed.', [
131-
`reinstall it: ${theme.command('brew install orbstack')}`,
132-
`or point the CLI elsewhere: unset DOCKER_HOST / ${theme.command('docker context use <name>')}`,
133-
])
134-
}
135-
throw new SetupError('No docker app is installed.', INSTALL_HINTS)
140+
return choice.explicit
141+
? launchFailed(required, 'The docker CLI is pointed at OrbStack, which is not installed.', [
142+
`reinstall it: ${theme.command('brew install orbstack')}`,
143+
`or point the CLI elsewhere: unset DOCKER_HOST and DOCKER_CONTEXT, then ${theme.command('docker context use <name>')}`,
144+
])
145+
: launchFailed(required, 'No docker app is installed.', INSTALL_HINTS)
136146
}
137147

138148
const spin = p.spinner()
139149
spin.start(`Waiting for the Docker daemon (${app.name})…`)
140150
const up = await waitFor(async () => daemonUp(), 90_000, 2000)
141151
spin.stop(up ? 'Docker is running' : `${glyph.fail} daemon did not come up`)
142152
if (!up) {
143-
throw new SetupError(`${app.name} did not start within 90s.`, [
153+
return launchFailed(required, `${app.name} did not start within 90s.`, [
144154
app === ORBSTACK_APP
145155
? 'open OrbStack manually once to finish its first-run setup, then re-run'
146156
: 'first-ever launch needs a GUI license acceptance — open Docker Desktop manually once, then re-run',

0 commit comments

Comments
 (0)