mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 01:29:56 +00:00
Fix plain openclaw startup on trusted POSIX Bun-only global installs by pinning the installed Bun executable. Keep paths as inert launcher data so released updaters can relocate them safely, with existing ownership, Doctor consent, and rollback handling. Validated 114 focused tests per runtime, package/tarball integrity, native published-9.7 plain/apostrophe upgrades, and byte-exact rollback controls. Document the inherited 9.7 readiness wait and the 9.6 upgrade limitation. CI exception: the only failing test job reproduces an inherited browser mock-cache defect already fixed on main by #162796; all other selected checks passed. Exact-head ClawSweeper found no actionable code issue.
46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
import { isAbsolute, join } from "node:path";
|
|
import {
|
|
getBunCliLauncherPathIssue,
|
|
inspectBunCliLauncher,
|
|
installBunCliLauncher,
|
|
resolveBunGlobalBinDir,
|
|
} from "./lib/bun-cli-launcher.mjs";
|
|
import {
|
|
detectLifecyclePackageManager,
|
|
probePackageCliNodeRuntime,
|
|
} from "./preinstall-package-manager-warning.mjs";
|
|
|
|
/** Complete only the Bun global link that this lifecycle already owns.
|
|
* @param {{packageRoot: string, env?: NodeJS.ProcessEnv, bunVersion?: string}} params
|
|
*/
|
|
export function installPackageBunCliLauncher(params) {
|
|
const env = params.env ?? process.env;
|
|
const bunPath = env.OPENCLAW_PACKAGE_BUN_LAUNCHER?.trim();
|
|
if (
|
|
process.platform === "win32" ||
|
|
!(params.bunVersion ?? process.versions.bun) ||
|
|
detectLifecyclePackageManager(env) !== "bun" ||
|
|
!bunPath ||
|
|
!isAbsolute(bunPath)
|
|
) {
|
|
return;
|
|
}
|
|
// Reuse preinstall's persistent-Node check; a Bun install with Node keeps its bin.
|
|
if (!probePackageCliNodeRuntime({ env, cwd: params.packageRoot })?.bunVersion) {
|
|
return;
|
|
}
|
|
if (
|
|
getBunCliLauncherPathIssue({ bunPath, entryPath: join(params.packageRoot, "openclaw.mjs") })
|
|
) {
|
|
return;
|
|
}
|
|
const binDir = resolveBunGlobalBinDir({ bunPath, env, cwd: params.packageRoot });
|
|
const target = { packageRoot: params.packageRoot, bunPath, binDir };
|
|
const inspected = inspectBunCliLauncher(target);
|
|
// A global symlink to this package is proof of ownership. Local dependency
|
|
// installs and non-inherited --config paths cannot claim an absent global bin.
|
|
if (inspected.state === "missing" || inspected.state === "conflict") {
|
|
return;
|
|
}
|
|
installBunCliLauncher(target);
|
|
}
|