@@ -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 = / l i b a t o m i c \. s o \. 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+
254280const 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" ) {
0 commit comments