Skip to content

Commit 28263a2

Browse files
committed
feat(satellite): enhance PATH for runtime checks in command execution
1 parent 5a0c5db commit 28263a2

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

services/satellite/src/utils/runtime-validator.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,43 @@ interface RuntimeCheckResult {
5757
allCommandsAvailable: boolean;
5858
}
5959

60+
/**
61+
* Build enhanced PATH for runtime checks
62+
* Includes common installation directories that might not be in systemd PATH
63+
*/
64+
function buildEnhancedPath(): string {
65+
const currentPath = process.env.PATH || '';
66+
const pathSegments = currentPath.split(':').filter(Boolean);
67+
68+
// Common installation locations (order matters - user local should come first)
69+
const commonPaths = [
70+
// User-local installations (using actual username, not hardcoded)
71+
`${process.env.HOME}/.local/bin`, // pip/uv user installs
72+
`${process.env.HOME}/.cargo/bin`, // Rust toolchain
73+
`${process.env.HOME}/bin`, // User bin directory
74+
75+
// System-wide package manager locations
76+
'/usr/local/bin', // Homebrew, manual installs
77+
'/usr/bin', // System packages
78+
'/bin', // Core system binaries
79+
80+
// Additional common locations
81+
'/opt/homebrew/bin', // macOS ARM Homebrew
82+
'/usr/local/sbin',
83+
'/usr/sbin',
84+
'/sbin'
85+
];
86+
87+
// Add common paths that aren't already in PATH
88+
for (const path of commonPaths) {
89+
if (path && !pathSegments.includes(path)) {
90+
pathSegments.push(path);
91+
}
92+
}
93+
94+
return pathSegments.join(':');
95+
}
96+
6097
/**
6198
* Check if command is available on the system (searches PATH)
6299
*/
@@ -66,7 +103,11 @@ function checkCommand(command: string, versionFlag: string): CommandCheckResult
66103
timeout: 5000,
67104
encoding: 'utf-8',
68105
stdio: ['ignore', 'pipe', 'pipe'],
69-
shell: false
106+
shell: true,
107+
env: {
108+
...process.env,
109+
PATH: buildEnhancedPath()
110+
}
70111
});
71112

72113
// Command not found
@@ -206,6 +247,12 @@ function buildWarningMessage(result: RuntimeCheckResult): string {
206247
return lines.join('\n');
207248
}
208249

250+
/**
251+
* Build enhanced PATH for runtime checks
252+
* Exported for potential reuse in process spawner
253+
*/
254+
export { buildEnhancedPath };
255+
209256
/**
210257
* Validate system runtimes before satellite starts
211258
*

0 commit comments

Comments
 (0)