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