@@ -2,6 +2,7 @@ import fs from 'node:fs/promises';
22import os from 'node:os' ;
33import path from 'node:path' ;
44import type { DependencyManagementService } from './dependency-management-service.js' ;
5+ import { ensureNoSpacePathAlias } from './pm2-home-alias.js' ;
56import type { PathManager } from './path-manager.js' ;
67import type { ActiveRuntimeDescriptor } from '../types/distribution-mode.js' ;
78
@@ -77,6 +78,15 @@ export class HagiscriptRuntimeContextResolver {
7778 const runtimeHome = path . resolve ( this . pathManager . getRuntimeProgramHome ( ) ) ;
7879 const runtimeDataRoot = path . resolve ( this . pathManager . getRuntimeDataHome ( ) ) ;
7980 const runtimeRoot = path . resolve ( input . activeRuntime . rootPath ) ;
81+ const aliasedRuntimeHome = await ensureNoSpacePathAlias ( runtimeHome , 'desktop-runtime-home' ) ;
82+ const aliasedRuntimeRoot = await ensureNoSpacePathAlias ( runtimeRoot , 'desktop-active-runtime-root' ) ;
83+ const dotnetRuntimeRoot = path . resolve ( this . pathManager . getEmbeddedRuntimeRoot ( this . pathManager . getCurrentPlatform ( ) ) ) ;
84+ const aliasedDotnetRuntimeRoot = await ensureNoSpacePathAlias ( dotnetRuntimeRoot , 'desktop-dotnet-runtime-root' ) ;
85+ const serviceWorkingDirectory = path . resolve ( input . serviceWorkingDirectory ) ;
86+ const aliasedServiceWorkingDirectory = await ensureNoSpacePathAlias (
87+ serviceWorkingDirectory ,
88+ 'desktop-service-working-directory' ,
89+ ) ;
8090 const runtimeLogsDirectory = path . join ( runtimeDataRoot , 'logs' ) ;
8191 const runtimeStateFilePath = path . join ( runtimeDataRoot , 'state.json' ) ;
8292 const serviceDataHome = path . join ( runtimeDataRoot , 'components' , SERVER_RUNTIME_DATA_DIR ) ;
@@ -90,14 +100,17 @@ export class HagiscriptRuntimeContextResolver {
90100 manifestPath ,
91101 `${ JSON . stringify (
92102 this . buildManifestOverride ( {
93- runtimeRoot,
94- runtimeHome,
103+ runtimeRoot : aliasedRuntimeRoot ,
104+ runtimeHome : aliasedRuntimeHome ,
95105 runtimeDataRoot,
96106 npmPrefix : path . resolve ( hagiscriptContext . environment . npmGlobalPrefix ) ,
97107 hagiscriptPackageRoot,
98- dotnetRuntimeRoot : path . resolve ( this . pathManager . getEmbeddedRuntimeRoot ( this . pathManager . getCurrentPlatform ( ) ) ) ,
99- servicePayloadPath : path . resolve ( input . servicePayloadPath ) ,
100- serviceWorkingDirectory : path . resolve ( input . serviceWorkingDirectory ) ,
108+ dotnetRuntimeRoot : aliasedDotnetRuntimeRoot ,
109+ servicePayloadPath : path . join (
110+ aliasedServiceWorkingDirectory ,
111+ path . basename ( path . resolve ( input . servicePayloadPath ) ) ,
112+ ) ,
113+ serviceWorkingDirectory : aliasedServiceWorkingDirectory ,
101114 serviceEnv : input . serviceEnv ?? { } ,
102115 } ) ,
103116 null ,
@@ -111,8 +124,8 @@ export class HagiscriptRuntimeContextResolver {
111124 hagiscriptExecutablePath,
112125 hagiscriptPackageRoot,
113126 commandEnv : hagiscriptContext . commandEnv ,
114- runtimeRoot,
115- runtimeHome,
127+ runtimeRoot : aliasedRuntimeRoot ,
128+ runtimeHome : aliasedRuntimeHome ,
116129 runtimeDataRoot,
117130 runtimeLogsDirectory,
118131 runtimeStateFilePath,
@@ -123,8 +136,11 @@ export class HagiscriptRuntimeContextResolver {
123136 manifestPath,
124137 manifestDirectory,
125138 appName : 'hagicode-server' ,
126- servicePayloadPath : path . resolve ( input . servicePayloadPath ) ,
127- serviceWorkingDirectory : path . resolve ( input . serviceWorkingDirectory ) ,
139+ servicePayloadPath : path . join (
140+ aliasedServiceWorkingDirectory ,
141+ path . basename ( path . resolve ( input . servicePayloadPath ) ) ,
142+ ) ,
143+ serviceWorkingDirectory : aliasedServiceWorkingDirectory ,
128144 cleanup : async ( ) => {
129145 await fs . rm ( manifestDirectory , { recursive : true , force : true } ) ;
130146 } ,
0 commit comments