Skip to content

Commit 69f5a2e

Browse files
t3dotggclaude
andcommitted
fix(cli): t3 starts on a fresh Ubuntu server without libatomic
Node's Linux runtime links libatomic.so.1, which Ubuntu server, cloud, and container images do not ship. The Linux CLI archive now carries lib/libatomic.so.1 and sets t3's RUNPATH to $ORIGIN/lib, so every launch path (install.sh, npx t3, the t3 up service, SSH and WSL installs) finds it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d7935f1 commit 69f5a2e

3 files changed

Lines changed: 55 additions & 8 deletions

File tree

‎.github/workflows/release-desktop.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,15 @@ jobs:
390390
mkdir -p "$target_dir"
391391
cp "native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"
392392
393+
- uses: ./.github/actions/setup-apt-mirrors
394+
if: inputs.platform == 'linux'
395+
396+
# The Linux archive ships libatomic.so.1 and points t3's RUNPATH at it.
397+
- name: Install patchelf
398+
if: inputs.cli_archive && inputs.platform == 'linux'
399+
shell: bash
400+
run: command -v patchelf || { sudo apt-get update && sudo apt-get install -y patchelf; }
401+
393402
- name: Build CLI archive
394403
if: inputs.cli_archive
395404
shell: bash
@@ -433,9 +442,6 @@ jobs:
433442
path: release-cli/*
434443
if-no-files-found: error
435444

436-
- uses: ./.github/actions/setup-apt-mirrors
437-
if: inputs.platform == 'linux'
438-
439445
- name: Install Linux desktop build libraries
440446
if: inputs.platform == 'linux'
441447
shell: bash

‎scripts/build-cli-archive.ts‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,32 @@ const stageWebClient = Effect.fn("stageWebClient")(function* (source: string, ta
251251
}
252252
});
253253

254+
/** Node links libatomic.so.1, which Ubuntu server and container images lack, so t3 carries its own. */
255+
const bundleLinuxLibatomic = Effect.fn("bundleLinuxLibatomic")(function* (input: {
256+
readonly contentDir: string;
257+
readonly executablePath: string;
258+
}) {
259+
const fs = yield* FileSystem.FileSystem;
260+
const path = yield* Path.Path;
261+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
262+
const ldd = yield* spawner.string(ChildProcess.make("ldd", [input.executablePath]));
263+
const source = /libatomic\.so\.1 => (\/\S+)/.exec(ldd)?.[1];
264+
if (source === undefined) {
265+
return yield* new CliArchiveInputMissingError({
266+
inputPath: "libatomic.so.1",
267+
hint: `ldd did not resolve it for ${input.executablePath}. Install libatomic1 on the build host.`,
268+
});
269+
}
270+
yield* fs.makeDirectory(path.join(input.contentDir, "lib"));
271+
yield* fs.copyFile(source, path.join(input.contentDir, "lib/libatomic.so.1"));
272+
// RUNPATH resolves through symlinks and is not inherited by child processes, unlike LD_LIBRARY_PATH.
273+
yield* runCommand(
274+
ChildProcess.make("patchelf", ["--set-rpath", "$ORIGIN/lib", input.executablePath]),
275+
"patchelf --set-rpath",
276+
);
277+
yield* Effect.log(`[cli-archive] Bundled ${source} as lib/libatomic.so.1.`);
278+
});
279+
254280
const MacSigningConfig = Config.all({
255281
identity: Config.String("T3CODE_CLI_MAC_SIGN_IDENTITY").pipe(Config.option),
256282
appleApiKey: Config.String("APPLE_API_KEY").pipe(Config.option),
@@ -444,11 +470,6 @@ const buildCliArchive = Effect.fn("buildCliArchive")(function* (input: {
444470
builtExecutable,
445471
`Run \`node apps/server/scripts/cli.ts build-exe${targetKey === hostKey ? "" : ` --target ${targetKey}`}\` first.`,
446472
);
447-
// TEMPORARY one-time Node fix. Remove when fixed: https://github.com/nodejs/node/issues/67048
448-
if (input.platform === "linux" && input.arch === "arm64") {
449-
const bytes = yield* fs.readFile(builtExecutable);
450-
yield* Effect.try(() => assertLinuxArm64PageCompatibility(bytes));
451-
}
452473
yield* requireInput(path.join(webClient, "index.html"), "Run `vp run --filter t3 build` first.");
453474
yield* requireInput(
454475
resourceMonitorDir,
@@ -473,6 +494,14 @@ const buildCliArchive = Effect.fn("buildCliArchive")(function* (input: {
473494
});
474495

475496
const executablePath = path.join(contentDir, executableName);
497+
if (input.platform === "linux") {
498+
yield* bundleLinuxLibatomic({ contentDir, executablePath });
499+
}
500+
// TEMPORARY one-time Node fix. Remove when fixed: https://github.com/nodejs/node/issues/67048
501+
if (input.platform === "linux" && input.arch === "arm64") {
502+
const bytes = yield* fs.readFile(executablePath);
503+
yield* Effect.try(() => assertLinuxArm64PageCompatibility(bytes));
504+
}
476505
if (input.platform === "mac") {
477506
yield* signMacArchiveContents({ repoRoot, contentDir, executablePath });
478507
} else if (input.platform === "win") {

‎scripts/smoke-cli-archive.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ const smokeCliArchive = Effect.fn("smokeCliArchive")(function* (input: {
106106
}
107107
}
108108

109+
// The runner has libatomic installed; fresh Ubuntu servers do not.
110+
if (platform === "linux") {
111+
const ldd = yield* spawner.string(ChildProcess.make("ldd", [executable]));
112+
const bundled = path.join(yield* fs.realPath(contentDir), "lib/libatomic.so.1");
113+
if (!ldd.includes(`libatomic.so.1 => ${bundled} `)) {
114+
return yield* new CliArchiveSmokeError({
115+
step: "checking that t3 loads the bundled libatomic",
116+
detail: ldd,
117+
});
118+
}
119+
}
120+
109121
const version = yield* runExecutable(executable, ["--version"], contentDir);
110122
if (version.exitCode !== 0 || !version.stdout.includes(input.expectVersion)) {
111123
return yield* new CliArchiveSmokeError({

0 commit comments

Comments
 (0)