mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-18 21:40:53 +00:00
Fix updater refresh cwd for service reinstall (#45452)
* Fix updater refresh cwd for service reinstall * Update: preserve relative env overrides during service refresh * Test: cover updater service refresh env rebasing
This commit is contained in:
@@ -69,6 +69,13 @@ import { suppressDeprecations } from "./suppress-deprecations.js";
|
||||
|
||||
const CLI_NAME = resolveCliName();
|
||||
const SERVICE_REFRESH_TIMEOUT_MS = 60_000;
|
||||
const SERVICE_REFRESH_PATH_ENV_KEYS = [
|
||||
"OPENCLAW_HOME",
|
||||
"OPENCLAW_STATE_DIR",
|
||||
"CLAWDBOT_STATE_DIR",
|
||||
"OPENCLAW_CONFIG_PATH",
|
||||
"CLAWDBOT_CONFIG_PATH",
|
||||
] as const;
|
||||
|
||||
const UPDATE_QUIPS = [
|
||||
"Leveled up! New skills unlocked. You're welcome.",
|
||||
@@ -117,6 +124,25 @@ function formatCommandFailure(stdout: string, stderr: string): string {
|
||||
return detail.split("\n").slice(-3).join("\n");
|
||||
}
|
||||
|
||||
function resolveServiceRefreshEnv(
|
||||
env: NodeJS.ProcessEnv,
|
||||
invocationCwd: string = process.cwd(),
|
||||
): NodeJS.ProcessEnv {
|
||||
const resolvedEnv: NodeJS.ProcessEnv = { ...env };
|
||||
for (const key of SERVICE_REFRESH_PATH_ENV_KEYS) {
|
||||
const rawValue = resolvedEnv[key]?.trim();
|
||||
if (!rawValue) {
|
||||
continue;
|
||||
}
|
||||
if (rawValue.startsWith("~") || path.isAbsolute(rawValue) || path.win32.isAbsolute(rawValue)) {
|
||||
resolvedEnv[key] = rawValue;
|
||||
continue;
|
||||
}
|
||||
resolvedEnv[key] = path.resolve(invocationCwd, rawValue);
|
||||
}
|
||||
return resolvedEnv;
|
||||
}
|
||||
|
||||
type UpdateDryRunPreview = {
|
||||
dryRun: true;
|
||||
root: string;
|
||||
@@ -190,6 +216,8 @@ async function refreshGatewayServiceEnv(params: {
|
||||
continue;
|
||||
}
|
||||
const res = await runCommandWithTimeout([resolveNodeRunner(), candidate, ...args], {
|
||||
cwd: params.result.root,
|
||||
env: resolveServiceRefreshEnv(process.env),
|
||||
timeoutMs: SERVICE_REFRESH_TIMEOUT_MS,
|
||||
});
|
||||
if (res.code === 0) {
|
||||
|
||||
Reference in New Issue
Block a user