Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(upgrade): reinstall global Bun packages with --backend=copyfile

garrytan51f1283d5611
diff --git a/docs/guides/upgrades-auto-update.md b/docs/guides/upgrades-auto-update.md
index 7706f714fb..ec55b62a4d 100644
--- a/docs/guides/upgrades-auto-update.md
+++ b/docs/guides/upgrades-auto-update.md
@@ -106,7 +106,7 @@ the startup Bun check, unlike `--version`). If the new release does not
start, the upgrade exits non-zero and prints recovery: `bun upgrade`, then
`gbrain post-upgrade`; or return to the previous release with
`git -C <clone> checkout <previous sha> && bun install` (bun-link) or
-`git ls-remote --exit-code --tags https://github.com/garrytan/gbrain refs/tags/v<previous> && bun remove -g gbrain && bun add -g github:garrytan/gbrain#v<previous>` (package; an in-place tag swap fails or silently corrupts the global lock on current Bun, #5034). Nothing is
+`git ls-remote --exit-code --tags https://github.com/garrytan/gbrain refs/tags/v<previous> && bun remove -g gbrain && bun add -g --backend=copyfile github:garrytan/gbrain#v<previous>` (package; every global reinstall copies files, because OpenClaw refuses a hardlinked plugin manifest; an in-place tag swap fails or silently corrupts the global lock on current Bun, #5034). Nothing is
rolled back automatically, and the autopilot channel records that version as
failed.
diff --git a/src/commands/upgrade.ts b/src/commands/upgrade.ts
index ba14e4a773..b7f2a7a23e 100644
--- a/src/commands/upgrade.ts
+++ b/src/commands/upgrade.ts
@@ -120,13 +120,13 @@ export async function runUpgrade(args: string[], opts: { targetVersion?: string
if (pinned) { if (pinned === 'refused') return; upgraded = pinned === 'installed'; break; }
if (checkBunFloor && refuseForBunFloor(await readPackageTarget(globalGbrainSpec(bunGlobalRoot)), opts.targetVersion)) return;
try {
- execFileSync('bun', ['update', 'gbrain'], { cwd: bunGlobalRoot, env: upgradeEnv, stdio: 'inherit', timeout: 120_000 });
+ execFileSync('bun', ['update', BUN_BACKEND, 'gbrain'], { cwd: bunGlobalRoot, env: upgradeEnv, stdio: 'inherit', timeout: 120_000 });
upgraded = true;
} catch {
if (installedDespiteFailure(oldVersion)) upgraded = true;
else {
console.error('Upgrade failed. Try running manually:');
- console.error(` cd ${bunGlobalRoot} && bun update gbrain`);
+ console.error(` cd ${bunGlobalRoot} && bun update ${BUN_BACKEND} gbrain`);
}
}
break;
@@ -200,7 +200,7 @@ export async function runUpgrade(args: string[], opts: { targetVersion?: string
default:
console.error('Could not detect installation method.');
console.log('Try one of:');
- console.log(' bun update gbrain');
+ console.log(` bun update ${BUN_BACKEND} gbrain`);
console.log(' clawhub update gbrain');
console.log(' Download from https://github.com/garrytan/gbrain/releases');
}
@@ -428,14 +428,14 @@ async function installStableRelease(method: string, target: { version: string; c
const bun = (bunArgs: string[]) => execFileSync('bun', bunArgs, { env: ctx.upgradeEnv, stdio: cliChildStdio(), timeout: 300_000 });
try {
bun(['remove', '-g', 'gbrain']);
- bun(['add', '-g', spec]);
+ bun(['add', '-g', BUN_BACKEND, spec]);
return 'installed';
} catch {
if (installedDespiteFailure(ctx.oldVersion)) return 'installed';
console.error(`Installing ${spec} failed. Restoring gbrain ${ctx.oldVersion}...`);
- try { bun(['add', '-g', `github:${GBRAIN_GITHUB_REPO}#v${ctx.oldVersion}`]); console.error(`Restored gbrain ${ctx.oldVersion}.`); }
+ try { bun(['add', '-g', BUN_BACKEND, `github:${GBRAIN_GITHUB_REPO}#v${ctx.oldVersion}`]); console.error(`Restored gbrain ${ctx.oldVersion}.`); }
catch { console.error(`Restore failed. Reinstall by hand: ${bunReinstallCommand(`#v${target.version}`)}`); }
- recordUpgradeError({ phase: ctx.phase ?? 'stable-reinstall', fromVersion: ctx.oldVersion, toVersion: target.version, error: `bun add -g ${spec} failed`, recover: bunReinstallCommand(`#v${target.version}`) });
+ recordUpgradeError({ phase: ctx.phase ?? 'stable-reinstall', fromVersion: ctx.oldVersion, toVersion: target.version, error: `bun add -g ${BUN_BACKEND} ${spec} failed`, recover: bunReinstallCommand(`#v${target.version}`) });
setCliExitVerdict(1);
return 'failed';
}
@@ -558,6 +558,13 @@ export function resolveBunGlobalRoot(): string {
return installRoot ?? defaultRoot;
}
+/**
+ * #8659: Bun's default backend hardlinks package files from its cache on Linux, and OpenClaw refuses a hardlinked
+ * plugin manifest, so a global install OpenClaw loads as a plugin stopped loading after every upgrade. Every global
+ * reinstall, and each hint that repeats one, copies the files instead.
+ */
+const BUN_BACKEND = '--backend=copyfile';
+
/**
* #5034 / B-NEW-5: reinstall the global Bun package at `ref` by removing it
* first. An in-place `bun add -g` / `bun install --global` tag swap over an
@@ -567,7 +574,7 @@ export function resolveBunGlobalRoot(): string {
*/
export function bunReinstallCommand(ref: string): string {
const tag = /^#(v\d[\w.]*)$/.exec(ref)?.[1];
- const remove = `bun remove -g gbrain && bun add -g github:${GBRAIN_GITHUB_REPO}${ref}`;
+ const remove = `bun remove -g gbrain && bun add -g ${BUN_BACKEND} github:${GBRAIN_GITHUB_REPO}${ref}`;
return tag ? `${releaseTagProbeCommand(tag)} && ${remove}` : remove;
}
@@ -633,13 +640,13 @@ export function planPinnedReinstall(requested: string | null, oldVersion: string
*/
export function reinstallHintLines(version: string, oldVersion: string, platform: NodeJS.Platform = process.platform): string[] {
const tag = `v${version}`;
- const restore = `If the add fails, restore ${oldVersion} with: bun add -g github:${GBRAIN_GITHUB_REPO}#v${oldVersion}`;
+ const restore = `If the add fails, restore ${oldVersion} with: bun add -g ${BUN_BACKEND} github:${GBRAIN_GITHUB_REPO}#v${oldVersion}`;
if (platform !== 'win32') return [bunReinstallCommand(`#${tag}`), restore];
return [
'Run these one at a time, and stop if the first one fails (the tag is not published yet):',
releaseTagProbeCommand(tag),
'bun remove -g gbrain',
- `bun add -g github:${GBRAIN_GITHUB_REPO}#${tag}`,
+ `bun add -g ${BUN_BACKEND} github:${GBRAIN_GITHUB_REPO}#${tag}`,
restore,
];
}
diff --git a/test/autopilot-unpublished-target-6828.test.ts b/test/autopilot-unpublished-target-6828.test.ts
index ded729cd3f..eba544c605 100644
--- a/test/autopilot-unpublished-target-6828.test.ts
+++ b/test/autopilot-unpublished-target-6828.test.ts
@@ -172,7 +172,7 @@ describe('#6828: auto-update while master is ahead of latest-stable', () => {
expect(tick.cache).toBe(`UP_TO_DATE ${VERSION}`);
expect(tick.out).toContain('RETURNED');
expect(tick.out).not.toContain('EXIT_CALLED');
- expect(tick.calls.filter((c) => c.includes('update gbrain') || c.startsWith('gbrain upgrade'))).toEqual([]);
+ expect(tick.calls.filter((c) => c.includes('update --backend=copyfile gbrain') || c.startsWith('gbrain upgrade'))).toEqual([]);
expect(tick.audit.some((e) => e.reason === 'swapped; exiting for supervisor relaunch')).toBe(false);
const boot = await run(h, h.bootDriver);
@@ -188,7 +188,7 @@ describe('#6828: auto-update while master is ahead of latest-stable', () => {
const h = harness('noop', { cache: `UPGRADE_AVAILABLE ${VERSION} ${MASTER_AHEAD}` });
const tick = await run(h, h.driver, { FAKE_TARGET_VERSION: MASTER_AHEAD });
expect(tick.code, tick.err).toBe(0);
- expect(tick.calls).toContain('bun update gbrain');
+ expect(tick.calls).toContain('bun update --backend=copyfile gbrain');
expect(tick.out).toContain('RETURNED');
expect(tick.out).not.toContain('EXIT_CALLED');
expect(tick.out).not.toContain('Upgrade complete');
@@ -202,7 +202,7 @@ describe('#6828: auto-update while master is ahead of latest-stable', () => {
expect(tick.audit.at(-1).reason).toContain('nothing newer was installed');
const again = await run(h, h.driver, { FAKE_TARGET_VERSION: MASTER_AHEAD });
- expect(again.calls.filter((c) => c === 'bun update gbrain')).toHaveLength(1);
+ expect(again.calls.filter((c) => c === 'bun update --backend=copyfile gbrain')).toHaveLength(1);
expect(again.su.failed_versions).toBeUndefined();
const boot = await run(h, h.bootDriver);
@@ -250,7 +250,7 @@ describe('#6828 review replays', () => {
// A directory where the receipt goes: the swap cannot write it and the channel cannot read one.
mkdirSync(join(h.home, '.gbrain', 'swap-receipt.json'));
const tick = await run(h, h.driver, { FAKE_TARGET_VERSION: MASTER_AHEAD });
- expect(tick.calls).toContain('bun update gbrain');
+ expect(tick.calls).toContain('bun update --backend=copyfile gbrain');
expect(tick.out).not.toContain('EXIT_CALLED');
expect(tick.su.attempting_version).toBeUndefined();
expect(tick.su.failed_versions).toBeUndefined();
@@ -263,10 +263,10 @@ describe('#6828 review replays', () => {
const h = harness('throttle', { cache: `UPGRADE_AVAILABLE ${VERSION} ${MASTER_AHEAD}` });
setConfig(h, { last_check_ts: Date.now() - 25 * 60 * 60 * 1000 });
const tick = await run(h, h.driver, { FAKE_TARGET_VERSION: MASTER_AHEAD });
- expect(tick.calls).toContain('bun update gbrain');
+ expect(tick.calls).toContain('bun update --backend=copyfile gbrain');
setConfig(h, { last_check_ts: Date.now() - 23 * 60 * 60 * 1000 });
const held = await run(h, h.driver, { FAKE_TARGET_VERSION: MASTER_AHEAD });
- expect(held.calls.filter((c) => c === 'bun update gbrain')).toHaveLength(1);
+ expect(held.calls.filter((c) => c === 'bun update --backend=copyfile gbrain')).toHaveLength(1);
}, 90_000);
test('the version the install would get is checked against known-bad, not only the checked version', async () => {
@@ -274,7 +274,7 @@ describe('#6828 review replays', () => {
const h = harness('gate-installed', { cache: `UPGRADE_AVAILABLE ${VERSION} ${MASTER_AHEAD}` });
setConfig(h, { failed_versions: [delivered] });
const tick = await run(h, h.driver, { FAKE_TARGET_VERSION: delivered });
- expect(tick.calls.filter((c) => c === 'bun update gbrain')).toEqual([]);
+ expect(tick.calls.filter((c) => c === 'bun update --backend=copyfile gbrain')).toEqual([]);
expect(tick.audit.at(-1)).toMatchObject({ action: 'known_bad', outcome: 'skipped', latest: MASTER_AHEAD });
expect(tick.audit.at(-1).reason).toContain(delivered);
}, 90_000);
diff --git a/test/upgrade-exact-tag-pin.test.ts b/test/upgrade-exact-tag-pin.test.ts
index 99a7552db4..e9c4894c96 100644
--- a/test/upgrade-exact-tag-pin.test.ts
+++ b/test/upgrade-exact-tag-pin.test.ts
@@ -78,13 +78,13 @@ describe('#5311 bare upgrade on an exact-tag pin', () => {
expect(r.stderr).toContain('Upgrade did not take effect');
expect(r.stderr).toContain(`pinned to github:garrytan/gbrain#v${VERSION}`);
// #5034 / B-NEW-5: remove before add; an in-place global tag swap fails (Bun 1.3) or silently corrupts the lock (Bun 1.4).
- expect(r.stderr).toContain('bun remove -g gbrain && bun add -g github:garrytan/gbrain');
+ expect(r.stderr).toContain('bun remove -g gbrain && bun add -g --backend=copyfile github:garrytan/gbrain');
expect(r.stderr).not.toContain('not published yet');
- expect(readFileSync(join(r.home, 'bun-calls.log'), 'utf-8')).toContain('update gbrain');
+ expect(readFileSync(join(r.home, 'bun-calls.log'), 'utf-8')).toContain('update --backend=copyfile gbrain');
// No false "just upgraded" breadcrumb for an upgrade that never happened.
expect(existsSync(join(r.home, '.gbrain', 'just-upgraded-from'))).toBe(false);
const errors = readFileSync(join(r.home, '.gbrain', 'upgrade-errors.jsonl'), 'utf-8').trim().split('\n').map(l => JSON.parse(l));
- expect(errors.some(e => e.phase === 'verify-pin' && e.hint.startsWith('bun remove -g gbrain && bun add -g github:garrytan/gbrain'))).toBe(true);
+ expect(errors.some(e => e.phase === 'verify-pin' && e.hint.startsWith('bun remove -g gbrain && bun add -g --backend=copyfile github:garrytan/gbrain'))).toBe(true);
} finally {
rmSync(r.home, { recursive: true, force: true });
}
@@ -113,8 +113,8 @@ describe('#5311 bare upgrade on an exact-tag pin', () => {
test('every reinstall hint removes the global package before adding the tag (#5034, B-NEW-5)', () => {
// #6662: a tag reinstall first proves the tag exists, so a missing tag stops before the removal.
- expect(bunReinstallCommand('#v0.60.1.0')).toBe('git ls-remote --exit-code --tags https://github.com/garrytan/gbrain refs/tags/v0.60.1.0 && bun remove -g gbrain && bun add -g github:garrytan/gbrain#v0.60.1.0');
- expect(bunReinstallCommand('')).toBe('bun remove -g gbrain && bun add -g github:garrytan/gbrain');
+ expect(bunReinstallCommand('#v0.60.1.0')).toBe('git ls-remote --exit-code --tags https://github.com/garrytan/gbrain refs/tags/v0.60.1.0 && bun remove -g gbrain && bun add -g --backend=copyfile github:garrytan/gbrain#v0.60.1.0');
+ expect(bunReinstallCommand('')).toBe('bun remove -g gbrain && bun add -g --backend=copyfile github:garrytan/gbrain');
});
test('an unpinned install that is already current still succeeds', async () => {
diff --git a/test/upgrade-migration-outcome.test.ts b/test/upgrade-migration-outcome.test.ts
index 949d2cd027..96cc39b2f9 100644
--- a/test/upgrade-migration-outcome.test.ts
+++ b/test/upgrade-migration-outcome.test.ts
@@ -44,7 +44,7 @@ describe('gbrain upgrade migration ownership and outcome (#5693)', () => {
test('package postinstall under upgrade defers migrations to post-upgrade', () => {
const r = runUpgradeHarness({});
expect(r.status, r.out).toBe(0);
- expect(r.calls).toContain('bun:update gbrain:owns=1');
+ expect(r.calls).toContain('bun:update --backend=copyfile gbrain:owns=1');
expect(r.calls).not.toContain('gbrain:apply-migrations');
expect(r.calls).toContain('gbrain:post-upgrade');
expect(r.out).toContain(`Binary: installed ${NEWER}`);
diff --git a/test/upgrade-no-autopilot.serial.test.ts b/test/upgrade-no-autopilot.serial.test.ts
index 1fc73a1449..495c584125 100644
--- a/test/upgrade-no-autopilot.serial.test.ts
+++ b/test/upgrade-no-autopilot.serial.test.ts
@@ -28,7 +28,7 @@ describe('upgrade autopilot opt-out propagation', () => {
});
expect(result.status, result.stderr + result.stdout).toBe(0);
const calls = readFileSync(join(home, 'calls.log'), 'utf8');
- expect(calls).toContain('bun:update gbrain:no-autopilot=1');
+ expect(calls).toContain('bun:update --backend=copyfile gbrain:no-autopilot=1');
expect(calls).not.toContain('gbrain:apply-migrations');
expect(calls).toContain('gbrain:post-upgrade --no-autopilot-install:no-autopilot=1');
} finally {
diff --git a/test/upgrade-release-tag-hint.test.ts b/test/upgrade-release-tag-hint.test.ts
index 2a42a066ef..8e84e648ac 100644
--- a/test/upgrade-release-tag-hint.test.ts
+++ b/test/upgrade-release-tag-hint.test.ts
@@ -30,24 +30,24 @@ const TAGS = ['aaa\trefs/tags/v0.60.200.0', 'bbb\trefs/tags/v0.60.213.0', 'ccc\t
describe('#6662 reinstall hint', () => {
test('the tag probe runs before the removal, and the removal still precedes the add (#5034)', () => {
const cmd = bunReinstallCommand('#v0.60.204.0');
- expect(cmd).toBe('git ls-remote --exit-code --tags https://github.com/garrytan/gbrain refs/tags/v0.60.204.0 && bun remove -g gbrain && bun add -g github:garrytan/gbrain#v0.60.204.0');
+ expect(cmd).toBe('git ls-remote --exit-code --tags https://github.com/garrytan/gbrain refs/tags/v0.60.204.0 && bun remove -g gbrain && bun add -g --backend=copyfile github:garrytan/gbrain#v0.60.204.0');
expect(cmd.indexOf('git ls-remote')).toBeLessThan(cmd.indexOf('bun remove -g gbrain'));
expect(cmd.indexOf('bun remove -g gbrain')).toBeLessThan(cmd.indexOf('bun add -g'));
- expect(bunReinstallCommand('')).toBe('bun remove -g gbrain && bun add -g github:garrytan/gbrain');
+ expect(bunReinstallCommand('')).toBe('bun remove -g gbrain && bun add -g --backend=copyfile github:garrytan/gbrain');
});
test('POSIX hint is the guarded one-liner plus a restore line; Windows prints one step per line', () => {
expect(reinstallHintLines('0.60.213.0', '0.60.200.0', 'linux')).toEqual([
bunReinstallCommand('#v0.60.213.0'),
- 'If the add fails, restore 0.60.200.0 with: bun add -g github:garrytan/gbrain#v0.60.200.0',
+ 'If the add fails, restore 0.60.200.0 with: bun add -g --backend=copyfile github:garrytan/gbrain#v0.60.200.0',
]);
const win = reinstallHintLines('0.60.213.0', '0.60.200.0', 'win32');
expect(win.some(l => l.includes('&&'))).toBe(false);
expect(win.slice(1)).toEqual([
'git ls-remote --exit-code --tags https://github.com/garrytan/gbrain refs/tags/v0.60.213.0',
'bun remove -g gbrain',
- 'bun add -g github:garrytan/gbrain#v0.60.213.0',
- 'If the add fails, restore 0.60.200.0 with: bun add -g github:garrytan/gbrain#v0.60.200.0',
+ 'bun add -g --backend=copyfile github:garrytan/gbrain#v0.60.213.0',
+ 'If the add fails, restore 0.60.200.0 with: bun add -g --backend=copyfile github:garrytan/gbrain#v0.60.200.0',
]);
});
@@ -118,7 +118,7 @@ describe('#6662 upgrade on a pinned install whose target tag is missing', () =>
expect(r.stderr).toContain(`v${target} is not published yet`);
expect(r.stderr).toContain(`The newest published release is 98.0.0.0.`);
expect(r.stderr).toContain(bunReinstallCommand('#v98.0.0.0'));
- expect(r.stderr).toContain(`restore ${VERSION} with: bun add -g github:garrytan/gbrain#v${VERSION}`);
+ expect(r.stderr).toContain(`restore ${VERSION} with: bun add -g --backend=copyfile github:garrytan/gbrain#v${VERSION}`);
expect(r.stderr).not.toContain(`gbrain#v${target}`);
} finally {
rmSync(r.home, { recursive: true, force: true });
diff --git a/test/upgrade-stable-channel.test.ts b/test/upgrade-stable-channel.test.ts
index aa0c5dd129..dd35605ab6 100644
--- a/test/upgrade-stable-channel.test.ts
+++ b/test/upgrade-stable-channel.test.ts
@@ -113,8 +113,8 @@ async function runStableUpgrade(args: string[], opts: RunOpts = {}): Promise<Run
writeFileSync(state, VERSION);
writeFileSync(join(bin, 'git'), `#!/bin/sh\ncase "$1" in ls-remote) cat '${join(home, 'tags.txt')}'; exit 0;; esac\nexit 1\n`);
writeFileSync(join(home, 'tags.txt'), tags(opts.stableCommit === undefined ? C_NEWER : opts.stableCommit));
- // `bun add -g github:garrytan/gbrain#v<x>` installs <x>; `gbrain --version` reports what is installed.
- writeFileSync(join(bin, 'bun'), `#!/bin/sh\necho "$*" >> '${join(home, 'bun-calls.log')}'\n${opts.failAdd ? `case "$*" in "add -g github:garrytan/gbrain#v${opts.failAdd}") exit 1;; esac\n` : ''}case "$*" in "add -g github:garrytan/gbrain#v"*) echo "$3" | sed 's/.*#v//' > '${state}';; esac\nexit 0\n`);
+ // `bun add -g --backend=copyfile github:garrytan/gbrain#v<x>` installs <x>; `gbrain --version` reports what is installed.
+ writeFileSync(join(bin, 'bun'), `#!/bin/sh\necho "$*" >> '${join(home, 'bun-calls.log')}'\n${opts.failAdd ? `case "$*" in "add -g --backend=copyfile github:garrytan/gbrain#v${opts.failAdd}") exit 1;; esac\n` : ''}case "$*" in "add -g --backend=copyfile github:garrytan/gbrain#v"*) echo "$4" | sed 's/.*#v//' > '${state}';; esac\nexit 0\n`);
writeFileSync(join(bin, 'gbrain'), `#!/bin/sh\nif [ "$1" = "--version" ]; then echo "gbrain $(cat '${state}')"; exit 0; fi\necho "$*" >> '${join(home, 'gbrain-calls.log')}'\nexit 0\n`);
for (const f of ['git', 'bun', 'gbrain']) chmodSync(join(bin, f), 0o755);
if (opts.config) {
@@ -160,7 +160,7 @@ async function withRun(args: string[], opts: RunOpts, check: (r: Run) => void):
describe('gbrain upgrade on the stable channel', () => {
test('installs exactly the stable release pinned to its tag (remove, then add), not the newest release', () => withRun(['--channel', 'stable', '--swap-only'], {}, r => {
expect(r.stdout).toContain(`Stable channel: installing gbrain ${NEWER}`);
- expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${NEWER}`]);
+ expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${NEWER}`]);
expect(r.stdout).toContain(`Now running: gbrain ${NEWER}`);
expect(r.exitCode).toBe(0);
}));
@@ -177,18 +177,18 @@ describe('gbrain upgrade on the stable channel', () => {
}));
test('default flip: a home that never set a channel follows stable on a bare upgrade (repo-less config and no config at all)', async () => {
- await withRun(['--swap-only'], {}, r => expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${NEWER}`]));
+ await withRun(['--swap-only'], {}, r => expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${NEWER}`]));
await withRun(['--swap-only'], { config: { engine: 'pglite', database_path: '/tmp/gbrain-stable-example.pglite' } }, r => {
- expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${NEWER}`]);
+ expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${NEWER}`]);
});
});
test('self_upgrade.channel stable and GBRAIN_RELEASE_CHANNEL=stable both select stable over the other sources', async () => {
await withRun(['--swap-only'], { config: { engine: 'pglite', database_path: '/tmp/gbrain-stable-example.pglite', self_upgrade: { channel: 'stable' } } }, r => {
- expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${NEWER}`]);
+ expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${NEWER}`]);
});
await withRun(['--swap-only'], { config: { engine: 'pglite', database_path: '/tmp/gbrain-stable-example.pglite', self_upgrade: { channel: 'alpha' } }, env: { GBRAIN_RELEASE_CHANNEL: 'stable' } }, r => {
- expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${NEWER}`]);
+ expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${NEWER}`]);
});
});
@@ -200,12 +200,12 @@ describe('gbrain upgrade on the stable channel', () => {
test('known_bad: a build the record withdrew is moved to the current stable, the one move below the running build', () => withRun(['--channel', 'stable', '--swap-only'], { stableCommit: C_OLDER, record: record(OLDER, { known_bad: [VERSION] }) }, r => {
expect(r.stdout).toContain(`gbrain ${VERSION} was withdrawn from the stable channel`);
- expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${OLDER}`]);
+ expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${OLDER}`]);
expect(r.exitCode).toBe(0);
}));
test('a failed add restores the release that was installed and records the recovery step', () => withRun(['--channel', 'stable', '--swap-only'], { failAdd: NEWER }, r => {
- expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${NEWER}`, `add -g github:garrytan/gbrain#v${VERSION}`]);
+ expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${NEWER}`, `add -g --backend=copyfile github:garrytan/gbrain#v${VERSION}`]);
expect(r.stderr).toContain(`Restored gbrain ${VERSION}.`);
const rec = JSON.parse(readFileSync(join(r.home, '.gbrain', 'upgrade-errors.jsonl'), 'utf8').trim().split('\n').at(-1)!);
expect(rec).toMatchObject({ phase: 'stable-reinstall', from_version: VERSION, to_version: NEWER });
@@ -217,8 +217,8 @@ describe('gbrain upgrade on the stable channel', () => {
for (const channel of ['alpha', 'latest']) {
await withRun(['--channel', channel, '--swap-only'], { spec: 'github:garrytan/gbrain#0123456789abcdef0123456789abcdef01234567' }, r => {
expect(r.stdout).toContain('pinned to github:garrytan/gbrain#0123456789abcdef0123456789abcdef01234567');
- expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g github:garrytan/gbrain#v${NEWEST}`]);
- expect(r.bunCalls).not.toContain('update gbrain');
+ expect(r.bunCalls).toEqual(['remove -g gbrain', `add -g --backend=copyfile github:garrytan/gbrain#v${NEWEST}`]);
+ expect(r.bunCalls).not.toContain('update --backend=copyfile gbrain');
expect(r.stdout).toContain(`Now running: gbrain ${NEWEST}`);
expect(r.exitCode).toBe(0);
});
diff --git a/test/upgrade.serial.test.ts b/test/upgrade.serial.test.ts
index 872659df6d..d52ae9b45d 100644
--- a/test/upgrade.serial.test.ts
+++ b/test/upgrade.serial.test.ts
@@ -448,7 +448,7 @@ describe('runUpgrade target verification (#4366)', () => {
}
});
- test('bun global install: `bun update gbrain` runs in the bun global root', async () => {
+ test('bun global install: `bun update --backend=copyfile gbrain` runs in the bun global root', async () => {
const { home, stdout } = await runUpgradeAgainstFakeInstall({
observedVersion: OLD,
driverDir: join('global', 'node_modules', 'gbrain', 'src'),
@@ -461,7 +461,7 @@ describe('runUpgrade target verification (#4366)', () => {
try {
expect(stdout).toContain('Detected install method: bun');
const calls = readFileSync(join(home, 'calls.log'), 'utf-8').trim().split('\n');
- expect(calls).toEqual([`${realpathSync(join(home, 'global'))}|update gbrain`]);
+ expect(calls).toEqual([`${realpathSync(join(home, 'global'))}|update --backend=copyfile gbrain`]);
} finally {
rmSync(home, { recursive: true, force: true });
}