@@ -165,6 +165,47 @@ const localRemoteShellLayer = (home: string) =>
165165 ) ;
166166
167167describe ( "ssh tunnel scripts" , ( ) => {
168+ it . live ( "distinguishes an incompatible remote Node from a missing executable" , ( ) =>
169+ Effect . gen ( function * ( ) {
170+ const fs = yield * FileSystem . FileSystem ;
171+ const home = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-ssh-node-" } ) ;
172+ const spawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
173+ for ( const missing of [ false , true ] ) {
174+ const nodeFixture = missing
175+ ? 'command() { [ "$*" != "-v node" ] && type "$2"; }; '
176+ : 'node() { cat >/dev/null; printf "Remote node 18.20.8 does not satisfy required range >=999.0.0.\\n" >&2; return 1; }; ' ;
177+ const remoteShell = ChildProcessSpawner . make ( ( command ) => {
178+ if ( command . _tag !== "StandardCommand" ) return spawner . spawn ( command ) ;
179+ return spawner . spawn (
180+ ChildProcess . make (
181+ "sh" ,
182+ [ "-c" , `${ nodeFixture } eval "$(cat)"` , "sh" , ...commandArgs ( command ) . slice ( - 1 ) ] ,
183+ { ...command . options , env : { ...command . options . env , HOME : home } } ,
184+ ) ,
185+ ) ;
186+ } ) ;
187+ const result = yield * SshTunnel . launchOrReuseRemoteServer (
188+ { alias : "devbox" , hostname : "devbox" , username : null , port : null } ,
189+ undefined ,
190+ { nodeScriptPath : "/unused/server.ts" , nodeEngineRange : ">=999.0.0" } ,
191+ ) . pipe (
192+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , remoteShell ) ,
193+ Effect . result ,
194+ ) ;
195+ assert . isTrue ( Result . isFailure ( result ) ) ;
196+ if ( ! Result . isFailure ( result ) ) return ;
197+ assert . isTrue ( isSshCommandError ( result . failure ) ) ;
198+ if ( ! isSshCommandError ( result . failure ) ) return ;
199+ assert . equal ( result . failure . exitCode , 1 ) ;
200+ assert . equal ( result . failure . stderr . includes ( "missing node on PATH" ) , missing ) ;
201+ assert . equal (
202+ result . failure . stderr . includes ( "does not satisfy required range >=999.0.0" ) ,
203+ ! missing ,
204+ ) ;
205+ }
206+ } ) . pipe ( Effect . scoped , Effect . provide ( Layer . mergeAll ( NodeServices . layer , NodeCrypto . layer ) ) ) ,
207+ ) ;
208+
168209 it ( "rejects archive versions that are not a single exact version segment" , ( ) => {
169210 for ( const archiveVersion of [
170211 "../other" ,
0 commit comments