@@ -140,4 +140,40 @@ it.layer(NodeServices.layer)("t3 update launcher", (it) => {
140140 assert . equal ( yield * fs . readLink ( pinned ) , exe ( "1.5.0" ) ) ;
141141 } ) . pipe ( Effect . scoped , Effect . provideService ( HostProcessPlatform , "linux" ) ) ,
142142 ) ;
143+
144+ it . effect ( "still moves the PATH launcher when the install bin one cannot be rewritten" , ( ) =>
145+ Effect . gen ( function * ( ) {
146+ const fs = yield * FileSystem . FileSystem ;
147+ const path = yield * Path . Path ;
148+ const root = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-update-" } ) ;
149+ const baseDir = path . join ( root , ".t3" ) ;
150+ const exe = ( version : string ) => path . join ( baseDir , "runtime/versions" , version , "t3" ) ;
151+ const installed = path . join ( root , ".local/bin/t3" ) ;
152+ const onPath = path . join ( root , "bin/t3" ) ;
153+ for ( const file of [ exe ( "1.0.0" ) , exe ( "2.0.0" ) ] ) {
154+ yield * fs . makeDirectory ( path . dirname ( file ) , { recursive : true } ) ;
155+ yield * fs . writeFileString ( file , "" ) ;
156+ }
157+ for ( const link of [ installed , onPath ] ) {
158+ yield * fs . makeDirectory ( path . dirname ( link ) , { recursive : true } ) ;
159+ yield * fs . symlink ( exe ( "1.0.0" ) , link ) ;
160+ }
161+ yield * fs . chmod ( path . dirname ( installed ) , 0o555 ) ;
162+
163+ yield * repointLauncherAfterSelfUpdate ( {
164+ baseDir,
165+ fromVersion : "1.0.0" ,
166+ targetVersion : "2.0.0" ,
167+ } ) . pipe (
168+ Effect . provideService ( HostProcessEnvironment , {
169+ HOME : root ,
170+ PATH : path . dirname ( onPath ) ,
171+ } ) ,
172+ Effect . ensuring ( fs . chmod ( path . dirname ( installed ) , 0o755 ) . pipe ( Effect . orDie ) ) ,
173+ ) ;
174+
175+ assert . equal ( yield * fs . readLink ( installed ) , exe ( "1.0.0" ) ) ;
176+ assert . equal ( yield * fs . readLink ( onPath ) , exe ( "2.0.0" ) ) ;
177+ } ) . pipe ( Effect . scoped , Effect . provideService ( HostProcessPlatform , "linux" ) ) ,
178+ ) ;
143179} ) ;
0 commit comments