Skip to content

lf update

Check whether a newer version of the LenserFight CLI is available and print the correct upgrade command for your package manager.

Usage

sh
lf update

Options

FlagTypeDefaultDescription
--checkbooleanfalseOnly check and report; do not print install commands
--jsonbooleanfalseOutput result as JSON

Examples

sh
# Interactive — shows update banner and install command
lf update

# CI-friendly — exits 0 always, result in JSON
lf update --json

# Only verify you are up to date
lf update --check

How it works

  1. Reads the installed version from the bundled package.json.
  2. Queries the npm registry (registry.npmjs.org/@lenserfight/cli/latest) with a 5-second timeout.
  3. Compares versions using semver. If the registry version is newer, it prints the appropriate update command.
  4. Caches the registry response in ~/.lenserfight/update-check.json for 24 hours to avoid repeated network calls.

Update commands by package manager

The CLI detects your package manager automatically:

sh
# npm global install
npm install -g @lenserfight/cli@latest

# pnpm global install
pnpm add -g @lenserfight/cli@latest

# yarn global install
yarn global add @lenserfight/cli@latest

"Cannot update in place" — permission errors

lf update checks that the install directory is writable before running your package manager. When it is not, the update stops with the blocked directory named, rather than letting npm fail with a wall of EACCES output:

 ERROR  Cannot update in place — the install directory is not writable by your account.

    install dir   /opt/homebrew/lib/node_modules/@lenserfight
    owned by      uid 501
    you are       uid 504

This happens when the CLI was installed by a different account than the one running it — common on a shared machine, or under a Homebrew-managed prefix owned by whoever installed Homebrew. Re-running the install, with or without sudo, does not fix the underlying ownership.

Three ways out, in rough order of preference:

sh
# 1. Run the update from the account that owns the install.

# 2. Take ownership of just this package, then re-run `lf update`.
sudo chown -R "$(id -un)" /opt/homebrew/lib/node_modules/@lenserfight

# 3. Move to a per-user global prefix, so updates never need elevation.
npm config set prefix ~/.npm-global
npm install -g @lenserfight/cli@latest
# then put ~/.npm-global/bin ahead of the old prefix on your PATH

sudo npm install -g also works, but under a Homebrew-managed prefix it leaves root-owned files behind that can break later brew commands.

Release channels

Channelnpm tagWho should use it
stablelatestProduction use; recommended for most users
betabetaPre-release feature testing
rcrcRelease candidates before stable
nightlynightlyBleeding-edge; may contain regressions

lf update always recommends the latest stable release. To install a pre-release channel:

sh
npm install -g @lenserfight/cli@beta
npm install -g @lenserfight/cli@rc
npm install -g @lenserfight/cli@nightly

Background update hint

After every command, the CLI checks the cache and prints a one-line hint to stderr if a newer version is available:

  ╭─────────────────────────────────────────────────────╮
  │  Update available: v0.10.0-alpha.2 → v0.11.0        │
  │  Run `lf update` for upgrade instructions.          │
  ╰─────────────────────────────────────────────────────╯

The hint:

  • Only appears when the cache already contains a newer version — it does not make a network call on every command.
  • Writes to stderr, never stdout, so scripts and --json output are unaffected.
  • Is suppressed in --local mode and when LF_NO_UPDATE_CHECK=1.

Suppress update checks

sh
# Per-invocation
lf --local <command>

# Process-wide
LF_NO_UPDATE_CHECK=1 lf <command>

Invalidate the cache

Delete the cache file to force an immediate check on the next command:

sh
rm ~/.lenserfight/update-check.json

After updating

Run lf doctor to verify your environment is healthy:

sh
lf doctor

JSON output schema

json
{
  "current": "0.2.0",
  "latest": "0.3.0",
  "hasUpdate": true
}

When the registry is unreachable:

json
{
  "current": "0.2.0",
  "latest": null,
  "hasUpdate": false
}

Security

  • The CLI never executes shell commands on your behalf. It only prints the update command for you to run.
  • Registry requests use HTTPS and a strict 5-second abort timeout.
  • The cache file contains only version strings and a timestamp — no credentials, no personal data.

  • lf doctor — validate environment health after upgrading
  • lf whats-new — print recent changelog entries
  • lf status — show current auth and environment state

lf update

Check for CLI updates and print upgrade instructions.

FlagTypeRequiredDescription
--checkbooleannoOnly check and print the result; do not print install commands
--jsonbooleannoOutput result as JSON