tscircuit / tscircuit/cli

Update prompt loops on every run (0.1.2020 → 0.1.2021): bundled version is stale because build runs before `pver release`

Open
#4,628 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
18
Forks
91
Avg merge
31m
Merged PRs (30d)
349

Description

Summary

Every run of tsci (e.g. tsci init) on the current latest release shows:

A new version of tsci is available (0.1.2020 → 0.1.2021).
Would you like to update now?

Accepting runs npm install -g tscircuit@latest (or the bun equivalent), which reinstalls the exact same version, and the prompt appears again on the next run. There is no way to satisfy the check.

Same symptom as the old #155, but with a different and reproducible root cause this time.

Environment

  • tscircuit@0.0.2465 (npm latest), which depends on @tscircuit/cli@^0.1.2021
  • @tscircuit/cli@0.1.2021 (npm latest)
  • Linux, Node v22.23.0 and Bun 1.2.14 — reproduces under both runtimes

Root cause

currentCliVersion() in lib/shared/check-for-cli-update.ts is:

export const currentCliVersion = () =>
  program?.version() ?? semver.inc(pkgVersion, "patch") ?? pkgVersion

where pkgVersion is imported from package.json and therefore inlined into dist/cli/main.js at build time. The +1 patch assumes the published version is always exactly one patch above the committed package.json version.

That assumption breaks because .github/workflows/bun-pver-release.yml runs bun run build before pver release bumps the version, and the committed package.json has fallen behind:

Source Version
package.json in main (last bump PR merged: #4510, 2026-08-27) 0.1.2019
var version = "…" inlined in the published dist/cli/main.js 0.1.2019
What the CLI reports for itself (0.1.2019 + 1 patch) 0.1.2020
package.json shipped on disk in @tscircuit/cli@0.1.2021 0.1.2021
https://registry.npmjs.org/@tscircuit/cli/latest 0.1.2021

So semver.gt("0.1.2021", "0.1.2020") is true forever for this build, and tsci --version --verbose prints @tscircuit/cli: 0.1.2020 even though the installed package is 0.1.2021.

Verified locally:

$ grep '"version"' node_modules/tscircuit/node_modules/@tscircuit/cli/package.json
  "version": "0.1.2021",
$ grep -n -m1 'var version = ' node_modules/tscircuit/node_modules/@tscircuit/cli/dist/cli/main.js
136147:var version = "0.1.2019";
$ tsci --version --verbose
tscircuit: 0.0.2465
@tscircuit/cli: 0.1.2020

Why the gap widened (and why no fix has shipped)

The version-bump PRs stopped merging after v0.1.2019, and the Publish to npm workflow has been failing on every push to main since (e.g. run 34154102423 on 2026-09-07). pver release starts from package.json (0.1.2019), finds tags 0.1.2020 … 0.1.2030 already taken, and aborts:

current version: 0.1.2019
candidate next version: 0.1.2020
Next version already exists as a git tag: 0.1.2020. Incrementing version by an increment.
…
Error: Next version already exists as a git tag: 0.1.2030. We tried to incremenet 10 times but the tag still exists. Consider deleting some git tags.

Git tags exist up to v0.1.2030 but npm stops at 0.1.2021, so nothing has been published since, and every user on tscircuit@latest is stuck in the update loop.

Suggested fixes

  1. Stop guessing the version. Read require("@tscircuit/cli/package.json").version at runtime (the on-disk file is correct: 0.1.2021) instead of inlining package.json and adding a patch. Alternatively, run bun run build after pver release bumps package.json, so the inlined value is right.
  2. Unblock the release pipeline: either bump package.json in main past 0.1.2030 or delete the orphan tags v0.1.2022v0.1.2030, and look into why the auto-merge of version-bumps/** PRs stopped after #4510.
  3. Minor: the check compares against @tscircuit/cli@latest but installs tscircuit@latest. If tscircuit has not yet been republished with the newer CLI, "updating" is a no-op and the prompt persists. Comparing against tscircuit@latest's pinned CLI version would avoid that.

Workaround for users

export TSCI_SKIP_CLI_UPDATE=true

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/shared/check-for-cli-update.ts and inspect how currentCliVersion() gets its package version in the built dist/cli/main.js. Then read .github/workflows/bun-pver-release.yml to trace the build and version-bump order. Done means the installed CLI reports its shipped version and no longer repeats the update prompt after updating.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
build-system, ci-cd, cli, release
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.