Skip to content

Commit bb92dc6

Browse files
authored
fix: stop --tag main from failing during npm pack (#125949)
* fix: refuse unsupported OpenClaw source package updates * refactor: narrow main update refusal
1 parent 3116923 commit bb92dc6

7 files changed

Lines changed: 55 additions & 31 deletions

File tree

‎docs/cli/update.md‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ openclaw update --channel extended-stable
2626
openclaw update --channel beta
2727
openclaw update --channel dev
2828
openclaw update --tag beta
29-
openclaw update --tag main
3029
openclaw update --dry-run
3130
openclaw update --no-restart
3231
openclaw update --yes
@@ -40,16 +39,16 @@ launcher scripts).
4039

4140
## Options
4241

43-
| Flag | Description |
44-
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
45-
| `--no-restart` | Skip restarting the Gateway service after a successful update. Package-manager updates that do restart verify the restarted service reports the expected version before the command succeeds. |
46-
| `--channel <stable\|extended-stable\|beta\|dev>` | Set the update channel and persist it after core update success. Extended-stable is package-only. |
47-
| `--tag <dist-tag\|version\|spec>` | Override the package target for this update only. It cannot be combined with an effective `extended-stable` channel, whose verified exact target is mandatory. For other package installs, `main` maps to `github:openclaw/openclaw#main`; GitHub/git source specs are packed into a temporary tarball before the staged global npm install. |
48-
| `--dry-run` | Preview planned actions (channel/tag/target/restart flow) without writing config, installing, syncing plugins, or restarting. |
49-
| `--json` | Print machine-readable `UpdateRunResult` JSON. Includes `postUpdate.plugins.warnings` when a managed plugin needs repair, beta-channel plugin fallback details, and `postUpdate.plugins.integrityDrifts` when npm plugin artifact drift is detected during post-update sync. |
50-
| `--timeout <seconds>` | Per-step timeout. Default `1800`. |
51-
| `--yes` | Skip confirmation prompts (for example downgrade confirmation). |
52-
| `--acknowledge-clawhub-risk` | Allow post-update plugin sync to continue past community ClawHub trust warnings without an interactive prompt. Without it, risky community releases are skipped and left unchanged when OpenClaw cannot prompt. Official ClawHub packages and bundled plugin sources bypass this prompt. |
42+
| Flag | Description |
43+
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
44+
| `--no-restart` | Skip restarting the Gateway service after a successful update. Package-manager updates that do restart verify the restarted service reports the expected version before the command succeeds. |
45+
| `--channel <stable\|extended-stable\|beta\|dev>` | Set the update channel and persist it after core update success. Extended-stable is package-only. |
46+
| `--tag <dist-tag\|version\|spec>` | Override the package target for this update only. It cannot be combined with an effective `extended-stable` channel, whose verified exact target is mandatory. Package installs reject the `main` shorthand; use `--channel dev` for the supported checkout and build flow. Other explicit package specs keep their package-manager behavior. |
47+
| `--dry-run` | Preview planned actions (channel/tag/target/restart flow) without writing config, installing, syncing plugins, or restarting. |
48+
| `--json` | Print machine-readable `UpdateRunResult` JSON. Includes `postUpdate.plugins.warnings` when a managed plugin needs repair, beta-channel plugin fallback details, and `postUpdate.plugins.integrityDrifts` when npm plugin artifact drift is detected during post-update sync. |
49+
| `--timeout <seconds>` | Per-step timeout. Default `1800`. |
50+
| `--yes` | Skip confirmation prompts (for example downgrade confirmation). |
51+
| `--acknowledge-clawhub-risk` | Allow post-update plugin sync to continue past community ClawHub trust warnings without an interactive prompt. Without it, risky community releases are skipped and left unchanged when OpenClaw cannot prompt. Official ClawHub packages and bundled plugin sources bypass this prompt. |
5352

5453
There is no `--verbose` flag. Use `--dry-run` to preview planned actions,
5554
`--json` for machine-readable results, and `openclaw update status --json`

‎docs/install/development-channels.md‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,18 @@ openclaw update --channel dev
7575
# Install a specific npm package spec
7676
openclaw update --tag [email protected]
7777

78-
# Install from GitHub main once without persisting the channel
79-
openclaw update --tag main
8078
```
8179

8280
Notes:
8381

8482
- `--tag` applies to **package (npm) installs only**; git installs ignore it.
8583
- The tag is not persisted; the next `openclaw update` uses the configured
8684
channel.
87-
- `--tag main` maps to the npm-compatible spec `github:openclaw/openclaw#main`
88-
for that one run. For a persistent moving `main` install, use
85+
- The `--tag main` shorthand is rejected for package installs because the
86+
workspace checkout is not a self-contained package artifact. Use
8987
`openclaw update --channel dev` (package installs switch to a git checkout)
9088
or reinstall with the installer's git method:
9189
`curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method git --version main`.
92-
The npm install path rejects GitHub/git source targets outright and points
93-
you at the git method instead.
9490
- Downgrade protection: if the target version is older than the current
9591
version, OpenClaw prompts for confirmation (skip with `--yes`).
9692
- Extended-stable always uses its verified exact package target. It is not a

‎docs/install/updating.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ OpenClaw cannot safely distinguish an old automatic pin from a user pin; run
6060
`openclaw plugins update @openclaw/name` once on the extended-stable channel
6161
to opt that plugin back into exact-core tracking.
6262

63-
`--channel dev` gives a persistent moving GitHub `main` checkout. For a one-off
64-
package update, `--tag main` maps to the `github:openclaw/openclaw#main` package
65-
spec and installs it directly through the target package manager (npm/pnpm/bun).
63+
`--channel dev` gives a persistent moving GitHub `main` checkout. Package
64+
installs reject the `--tag main` shorthand because the workspace checkout is
65+
not a self-contained package artifact. Use `openclaw update --channel dev` to
66+
switch to the supported checkout and build flow. Other explicit package specs
67+
keep their package-manager behavior.
6668

6769
For managed plugins, a missing beta release is a warning, not a failure: the
6870
core update can still succeed while a plugin falls back to its recorded

‎src/cli/update-cli.test.ts‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,12 +4355,6 @@ describe("update-cli", () => {
43554355
packageSpec: undefined,
43564356
expectedSpec: "[email protected]",
43574357
},
4358-
{
4359-
name: "main shorthand",
4360-
options: { yes: true, tag: "main" },
4361-
packageSpec: undefined,
4362-
expectedSpec: "github:openclaw/openclaw#main",
4363-
},
43644358
{
43654359
name: "explicit git package spec",
43664360
options: { yes: true, tag: "github:openclaw/openclaw#main" },
@@ -4429,6 +4423,33 @@ describe("update-cli", () => {
44294423
},
44304424
);
44314425

4426+
it.each([
4427+
{ name: "real run", options: { yes: true, json: true, tag: "main" } },
4428+
{ name: "normalized alias", options: { yes: true, json: true, tag: "openclaw@main" } },
4429+
{
4430+
name: "dry-run",
4431+
options: { dryRun: true, json: true, tag: "main", yes: true },
4432+
},
4433+
] as const)("refuses --tag main before package resolution: $name", async ({ options }) => {
4434+
mockPackageInstallStatus(createCaseDir("openclaw-update-main-refusal"));
4435+
4436+
await updateCommand(options);
4437+
4438+
const result = lastWriteJsonCall() as UpdateRunResult | undefined;
4439+
expect(result).toMatchObject({
4440+
status: "error",
4441+
reason: "unsupported-package-target",
4442+
steps: [],
4443+
});
4444+
expect(packageInstallCommandCall()).toBeUndefined();
4445+
expectNoSideEffects(resolveGlobalManager, replaceConfigFile, runGatewayUpdate);
4446+
if ("dryRun" in options && options.dryRun) {
4447+
expect(cleanupStaleManagedServiceUpdateHandoffs).not.toHaveBeenCalled();
4448+
}
4449+
expect(defaultRuntime.exit).toHaveBeenCalledWith(1);
4450+
expect(getErrorOutput()).toContain("openclaw update --channel dev");
4451+
});
4452+
44324453
it("fails package updates when the installed correction version does not match the requested target", async () => {
44334454
const tempDir = createCaseDir("openclaw-update");
44344455
const nodeModules = path.join(tempDir, "node_modules");

‎src/cli/update-cli.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ export function registerUpdateCli(program: Command) {
165165
["openclaw update --channel beta", "Switch to beta channel (git + npm)"],
166166
["openclaw update --channel dev", "Switch to dev channel (git + npm)"],
167167
["openclaw update --tag beta", "One-off update to a dist-tag or version"],
168-
["openclaw update --tag main", "One-off package update from GitHub main"],
169168
["openclaw update --dry-run", "Preview actions without changing anything"],
170169
["openclaw update --no-restart", "Update without restarting the service"],
171170
["openclaw update --json", "Output result as JSON"],
@@ -187,7 +186,7 @@ ${theme.heading("Switch channels:")}
187186
- Use --channel stable|extended-stable|beta|dev to persist the update channel in config
188187
- Run openclaw update status to see the active channel and source
189188
- Use --tag <dist-tag|version|spec> for a one-off package update without persisting
190-
- Use --tag main for a one-off package update from GitHub main
189+
- Use --channel dev for the moving GitHub main checkout; package installs reject --tag main
191190
192191
${theme.heading("Non-interactive:")}
193192
- Use --yes to accept downgrade prompts

‎src/cli/update-cli/update-command-post-core.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export async function reportPreMutationUpdateFailure(params: {
106106
reason:
107107
| ExtendedStableFailureReason
108108
| typeof EXTENDED_STABLE_TAG_UNSUPPORTED_REASON
109-
| "npm lifecycle policy preflight";
109+
| "npm lifecycle policy preflight"
110+
| "unsupported-package-target";
110111
message?: string;
111112
opts: UpdateCommandOptions;
112113
controlPlaneUpdateSentinelMeta: ControlPlaneUpdateSentinelMetaFile["meta"] | null;

‎src/cli/update-cli/update-command.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,17 @@ async function updateCommandInternal(
289289
}
290290

291291
const explicitTag = normalizeTag(opts.tag);
292-
if (channel === "extended-stable" && explicitTag) {
292+
const unsupportedMainTag = updateInstallKind === "package" && explicitTag === "main";
293+
if ((channel === "extended-stable" && explicitTag) || unsupportedMainTag) {
293294
await reportPreMutationUpdateFailure({
294295
root,
295296
installKind: updateInstallKind,
296-
reason: EXTENDED_STABLE_TAG_UNSUPPORTED_REASON,
297+
reason: unsupportedMainTag
298+
? "unsupported-package-target"
299+
: EXTENDED_STABLE_TAG_UNSUPPORTED_REASON,
300+
message: unsupportedMainTag
301+
? "`--tag main` cannot update a package install. Run `openclaw update --channel dev` to switch to the supported Git checkout and build flow."
302+
: undefined,
297303
opts,
298304
controlPlaneUpdateSentinelMeta,
299305
});

0 commit comments

Comments
 (0)