Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-12613]): print tail build lines on SuperCollider docker build failure

[._.]/ Adam Eivya0a034ee8286
diff --git a/docs/SUPERCOLLIDER.md b/docs/SUPERCOLLIDER.md
index cf6986c3e3..0b888c516d 100644
--- a/docs/SUPERCOLLIDER.md
+++ b/docs/SUPERCOLLIDER.md
@@ -184,7 +184,9 @@ Both first setup runs built the image and passed the stock-synth probe. Both sec
## Troubleshooting
-- **Build fails fetching packages**: `snapshot.debian.org` is occasionally slow or rate-limited. Apt retries five times. Re-run setup; Docker reuses completed layers.
+On an image build failure, setup retains and prints the trailing build lines (such as compiler or package download errors) directly in the CLI and CI failure log so the failure is diagnosable without re-running. If needed, re-run with `--verbose` for the full build log from the start.
+
+- **Build fails fetching packages**: `snapshot.debian.org` is occasionally slow or rate-limited. Apt retries five times. On build failure, setup prints the failing package lines (`E: ...`) directly in the error output. Re-run setup; Docker reuses completed layers.
- **Build fails downloading the SuperCollider source, or the checksum fails**: the GitHub release asset was unreachable or altered. The build stops at the checksum rather than compiling unverified source.
- **`smoke-failed`**: read `smoke.error`, then try `npm run setup:supercollider -- --yes --rebuild`, which rebuilds without the layer cache.
- **`docker-stopped` right after starting Docker Desktop**: the engine can take a minute to come up. Re-run once it reports running.
diff --git a/scripts/setup-supercollider.js b/scripts/setup-supercollider.js
index 90d50b9214..c682611783 100644
--- a/scripts/setup-supercollider.js
+++ b/scripts/setup-supercollider.js
@@ -51,25 +51,29 @@ export const exitCodeForOutcome = (outcome) => SETUP_EXIT_CODES[outcome] ?? SETU
// headers (BuildKit `#N [stage x/y] …`, classic builder `Step x/y : …`).
export const isBuildStepLine = (line) => /^#\d+ \[[^\]]+\]/.test(line) || /^Step \d+\/\d+ :/.test(line);
+/** Bounded ring buffer size for lines not shown in non-verbose build mode. */
+export const BUILD_LINE_BUFFER_LIMIT = 40;
+
const mark = (ok) => (ok ? '✅' : '❌');
-function printStatus(status) {
+function printStatus(status, { log = console.log, warn = console.warn } = {}) {
+ if (!status) return;
const { docker, image, smoke, runtime } = status;
- const dockerLine = !docker.installed ? 'not installed'
+ const dockerLine = !docker?.installed ? 'not installed'
: !docker.running ? `installed, engine not reachable${docker.error ? ` (${docker.error})` : ''}`
: `${docker.serverVersion} (${docker.os}/${docker.arch})`;
- console.log(`${mark(docker.running)} Docker: ${dockerLine}`);
- const imageLine = !image ? `${runtime.image} not built`
- : `${runtime.image}${image.sizeBytes ? ` (${Math.round(image.sizeBytes / 1e6)} MB)` : ''}${image.current ? '' : ` — stale (built for ${image.runtimeVersion || 'an unknown version'})`}`;
- console.log(`${mark(image?.current)} Image: ${imageLine}`);
+ log(`${mark(docker?.running)} Docker: ${dockerLine}`);
+ const imageLine = !image ? `${runtime?.image ?? 'supercollider'} not built`
+ : `${runtime?.image ?? 'supercollider'}${image.sizeBytes ? ` (${Math.round(image.sizeBytes / 1e6)} MB)` : ''}${image.current ? '' : ` — stale (built for ${image.runtimeVersion || 'an unknown version'})`}`;
+ log(`${mark(image?.current)} Image: ${imageLine}`);
const smokeLine = !smoke ? 'not run'
: !smoke.current ? `stale (last run ${smoke.checkedAt} against a different image/runtime/policy)`
- : smoke.ok ? `passed ${smoke.checkedAt} — ${smoke.measurement.durationMs} ms, ${smoke.measurement.channels} ch, ${smoke.measurement.sampleRate} Hz, peak ${smoke.measurement.peak}`
+ : smoke.ok ? `passed ${smoke.checkedAt} — ${smoke.measurement?.durationMs} ms, ${smoke.measurement?.channels} ch, ${smoke.measurement?.sampleRate} Hz, peak ${smoke.measurement?.peak}`
: `failed ${smoke.checkedAt}: ${smoke.error}`;
- console.log(`${mark(smoke?.current && smoke.ok)} Render probe: ${smokeLine}`);
- const log = status.ready ? console.log : console.warn;
- log(`${status.ready ? '🎛️' : '⚠️'} ${status.message}`);
- if (status.action) log(`👉 ${status.action}`);
+ log(`${mark(smoke?.current && smoke.ok)} Render probe: ${smokeLine}`);
+ const msgLog = status.ready ? log : warn;
+ msgLog(`${status.ready ? '🎛️' : '⚠️'} ${status.message}`);
+ if (status.action) msgLog(`👉 ${status.action}`);
}
function ask(question) {
@@ -85,26 +89,53 @@ async function confirmBuild({ yes }) {
return false;
}
-async function main() {
- const options = parseSuperColliderSetupArgs(process.argv.slice(2));
+export async function main(argv = process.argv.slice(2), io = {}) {
+ const log = io.log ?? console.log;
+ const error = io.error ?? console.error;
+ const warn = io.warn ?? console.warn;
+ const setupRuntime = io.setupSuperColliderRuntime ?? setupSuperColliderRuntime;
+ const getStatus = io.getSuperColliderStatus ?? getSuperColliderStatus;
+ const options = parseSuperColliderSetupArgs(argv);
if (options.status) {
- const status = await getSuperColliderStatus();
- if (options.json) console.log(JSON.stringify(status, null, 2));
- else printStatus(status);
- return;
+ const status = await getStatus();
+ if (options.json) log(JSON.stringify(status, null, 2));
+ else printStatus(status, { log, warn });
+ return { outcome: status.ready ? 'ready' : status.state, status };
}
- console.log('🎛️ SuperCollider runtime setup');
- const result = await setupSuperColliderRuntime({
+ log('🎛️ SuperCollider runtime setup');
+ const retainedLines = [];
+ const result = await setupRuntime({
rebuild: options.rebuild,
- confirmBuild: () => confirmBuild(options),
- onLine: (line) => { if (options.verbose || isBuildStepLine(line)) console.log(` ${line}`); },
+ confirmBuild: io.confirmBuild ?? (() => confirmBuild(options)),
+ onLine: (line) => {
+ if (options.verbose || isBuildStepLine(line)) {
+ log(` ${line}`);
+ } else {
+ retainedLines.push(line);
+ if (retainedLines.length > BUILD_LINE_BUFFER_LIMIT) {
+ retainedLines.shift();
+ }
+ }
+ },
});
- if (result.built) console.log('✅ Image built');
- else if (result.outcome === 'ready' || result.outcome === 'smoke-failed') console.log('✅ Image already current — skipped the build');
- if (result.probed) console.log(`${result.status.ready ? '✅' : '❌'} Synthetic render probe ${result.status.ready ? 'passed' : 'failed'}`);
- if (result.outcome === 'build-failed') console.error(`❌ Image build failed: ${result.error}`);
- printStatus(result.status);
- process.exitCode = exitCodeForOutcome(result.outcome);
+ if (result.built) log('✅ Image built');
+ else if (result.outcome === 'ready' || result.outcome === 'smoke-failed') log('✅ Image already current — skipped the build');
+ if (result.probed) log(`${result.status?.ready ? '✅' : '❌'} Synthetic render probe ${result.status?.ready ? 'passed' : 'failed'}`);
+ if (result.outcome === 'build-failed') {
+ error(`❌ Image build failed: ${result.error}`);
+ if (!options.verbose) {
+ for (const line of retainedLines) {
+ error(` ${line}`);
+ }
+ error('👉 Re-run with --verbose for the full build log');
+ }
+ }
+ printStatus(result.status, { log, warn });
+ const exitCode = exitCodeForOutcome(result.outcome);
+ if (io.setExitCode !== false) {
+ process.exitCode = exitCode;
+ }
+ return { ...result, exitCode };
}
if (isDirectlyInvoked(import.meta.url)) {
diff --git a/scripts/setup-supercollider.test.js b/scripts/setup-supercollider.test.js
index 20c278047c..714a8bade2 100644
--- a/scripts/setup-supercollider.test.js
+++ b/scripts/setup-supercollider.test.js
@@ -1,5 +1,11 @@
import { describe, expect, it } from 'vitest';
-import { exitCodeForOutcome, isBuildStepLine, parseSuperColliderSetupArgs } from './setup-supercollider.js';
+import {
+ BUILD_LINE_BUFFER_LIMIT,
+ exitCodeForOutcome,
+ isBuildStepLine,
+ main,
+ parseSuperColliderSetupArgs,
+} from './setup-supercollider.js';
describe('SuperCollider setup CLI', () => {
it('accepts only the documented flags', () => {
@@ -22,4 +28,174 @@ describe('SuperCollider setup CLI', () => {
expect(isBuildStepLine('Step 4/12 : RUN apt-get update')).toBe(true);
expect(isBuildStepLine('#7 412.3 [ 61%] Building CXX object server/plugins/BinaryOpUGens.cpp.o')).toBe(false);
});
+
+ function makeSimulatedBuildStream() {
+ const lines = [
+ '#1 [internal] load build definition from Dockerfile',
+ '#2 [internal] load .dockerignore',
+ '#3 [1/4] FROM debian:bookworm-slim',
+ '#4 [2/4] RUN apt-get update && apt-get install -y',
+ ];
+ // ~100 apt lines with an E: error within the last 40 lines
+ for (let i = 1; i <= 75; i++) {
+ lines.push(`#4 1.${i} Get:${i} http://deb.debian.org/debian bookworm/main amd64 Packages [${i * 10} kB]`);
+ }
+ lines.push('#4 12.3 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?');
+ for (let i = 76; i <= 99; i++) {
+ lines.push(`#4 12.${i} W: Failed to fetch http://deb.debian.org/debian/pool/main/pkg-${i}.deb`);
+ }
+ lines.push('#4 ERROR: process "/bin/sh -c apt-get update..." did not complete successfully: exit code: 100');
+ lines.push('------ (buildkit excerpt)');
+ lines.push(' > [2/4] RUN apt-get update && apt-get install -y:');
+ lines.push('------------------------');
+ lines.push('failed to solve: process "/bin/sh -c ..." did not complete successfully: exit code: 100');
+ return lines;
+ }
+
+ const baseStatus = {
+ docker: { installed: true, running: true, serverVersion: '27.0.3', os: 'linux', arch: 'x64' },
+ image: null,
+ smoke: null,
+ runtime: { image: 'portos-supercollider:current' },
+ };
+
+ it('retains and prints at most 40 tail build lines including the E: error line on failure', async () => {
+ const stdout = [];
+ const stderr = [];
+ const stream = makeSimulatedBuildStream();
+ const buildError = 'failed to solve: process "/bin/sh -c ..." did not complete successfully: exit code: 100';
+
+ const result = await main(['--yes'], {
+ log: (m) => stdout.push(m),
+ error: (m) => stderr.push(m),
+ warn: (m) => stderr.push(m),
+ setExitCode: false,
+ setupSuperColliderRuntime: async ({ onLine }) => {
+ for (const line of stream) onLine(line);
+ return {
+ outcome: 'build-failed',
+ built: false,
+ probed: false,
+ error: buildError,
+ status: { ...baseStatus, ready: false, message: 'Docker image build failed', action: 'Inspect Docker logs' },
+ };
+ },
+ });
+
+ expect(result.exitCode).toBe(4);
+
+ // Verify step headers were printed during build to stdout
+ expect(stdout).toContain(' #1 [internal] load build definition from Dockerfile');
+ expect(stdout).toContain(' #4 [2/4] RUN apt-get update && apt-get install -y');
+
+ // Verify failure output in stderr contains the error header, the E: line, and re-run advice
+ const failureHeaderIdx = stderr.findIndex((l) => l.startsWith('❌ Image build failed:'));
+ const rerunTipIdx = stderr.findIndex((l) => l === '👉 Re-run with --verbose for the full build log');
+
+ expect(failureHeaderIdx).toBeGreaterThanOrEqual(0);
+ expect(rerunTipIdx).toBeGreaterThan(failureHeaderIdx);
+
+ const retainedLines = stderr.slice(failureHeaderIdx + 1, rerunTipIdx);
+ expect(retainedLines.length).toBeLessThanOrEqual(40);
+ expect(retainedLines.length).toBe(BUILD_LINE_BUFFER_LIMIT);
+ expect(retainedLines.some((l) => l.includes('E: Unable to fetch some archives'))).toBe(true);
+ expect(retainedLines.every((l) => l.startsWith(' '))).toBe(true);
+ });
+
+ it('prints nothing extra on a successful build', async () => {
+ const stdout = [];
+ const stderr = [];
+ const stream = makeSimulatedBuildStream();
+
+ const result = await main(['--yes'], {
+ log: (m) => stdout.push(m),
+ error: (m) => stderr.push(m),
+ warn: (m) => stderr.push(m),
+ setExitCode: false,
+ setupSuperColliderRuntime: async ({ onLine }) => {
+ for (const line of stream) onLine(line);
+ return {
+ outcome: 'ready',
+ built: true,
+ probed: true,
+ error: null,
+ status: {
+ ...baseStatus,
+ ready: true,
+ image: { current: true, sizeBytes: 150_000_000 },
+ smoke: { ok: true, current: true, checkedAt: '2026-10-20', measurement: { durationMs: 50, channels: 2, sampleRate: 48000, peak: 0.9 } },
+ message: 'SuperCollider runtime is ready',
+ },
+ };
+ },
+ });
+
+ expect(result.exitCode).toBe(0);
+ expect(stderr).toEqual([]);
+ expect(stdout.some((l) => l.includes('Re-run with --verbose'))).toBe(false);
+ expect(stdout.some((l) => l.includes('E: Unable to fetch'))).toBe(false);
+ // Non-step lines should not appear in stdout
+ expect(stdout.some((l) => l.includes('W: Failed to fetch'))).toBe(false);
+ });
+
+ it('prints no duplicate lines on a non-verbose failure', async () => {
+ const stdout = [];
+ const stderr = [];
+ const stream = makeSimulatedBuildStream();
+
+ await main(['--yes'], {
+ log: (m) => stdout.push(m),
+ error: (m) => stderr.push(m),
+ warn: (m) => stderr.push(m),
+ setExitCode: false,
+ setupSuperColliderRuntime: async ({ onLine }) => {
+ for (const line of stream) onLine(line);
+ return {
+ outcome: 'build-failed',
+ built: false,
+ probed: false,
+ error: 'build failed',
+ status: { ...baseStatus, ready: false, message: 'Docker image build failed' },
+ };
+ },
+ });
+
+ const allOutputLines = [...stdout, ...stderr];
+ const uniqueLines = new Set(allOutputLines);
+ expect(uniqueLines.size).toBe(allOutputLines.length);
+
+ // Specifically verify no line printed to stdout during build was repeated in stderr
+ const overlap = stdout.filter((line) => stderr.includes(line));
+ expect(overlap).toEqual([]);
+ });
+
+ it('keeps --verbose output unchanged on build failure', async () => {
+ const stdout = [];
+ const stderr = [];
+ const stream = makeSimulatedBuildStream();
+
+ const result = await main(['--yes', '--verbose'], {
+ log: (m) => stdout.push(m),
+ error: (m) => stderr.push(m),
+ warn: (m) => stderr.push(m),
+ setExitCode: false,
+ setupSuperColliderRuntime: async ({ onLine }) => {
+ for (const line of stream) onLine(line);
+ return {
+ outcome: 'build-failed',
+ built: false,
+ probed: false,
+ error: 'build failed',
+ status: { ...baseStatus, ready: false, message: 'Docker image build failed' },
+ };
+ },
+ });
+
+ expect(result.exitCode).toBe(4);
+ // In verbose mode, every line is streamed to stdout
+ expect(stdout.some((l) => l.includes('E: Unable to fetch'))).toBe(true);
+ // stderr has the error header and status, but NO retained line buffer or re-run advice
+ expect(stderr.some((l) => l.includes('Re-run with --verbose'))).toBe(false);
+ expect(stderr.some((l) => l.includes('E: Unable to fetch'))).toBe(false);
+ });
});