Skip to content

fix(self-update): ensure subcommand exists#9144

Merged
jdx merged 4 commits intojdx:mainfrom
salim-b:fix-self-update-stub
Apr 16, 2026
Merged

fix(self-update): ensure subcommand exists#9144
jdx merged 4 commits intojdx:mainfrom
salim-b:fix-self-update-stub

Conversation

@salim-b
Copy link
Copy Markdown
Contributor

@salim-b salim-b commented Apr 16, 2026

even when the self_update Cargo feature is disabled.

Before, the SelfUpdate enum variant in src/cli/mod.rs inside the Commands enum was gated with #[cfg(feature = "self_update")]. This meant that when compiling without the self_update feature, the subcommand would be completely omitted from the CLI parser, instead of using the stub.

Furthermore, the SelfUpdate struct in src/cli/self_update_stub.rs did not derive the clap::Parser trait, nor did it have an asynchronous run method, which is required by the subcommand runner in src/cli/mod.rs.

even when the `self_update` Cargo feature is disabled.

Before, the `SelfUpdate` enum variant in `src/cli/mod.rs` inside the
`Commands` enum was gated with `#[cfg(feature = "self_update")]`. This
meant that when compiling without the `self_update` feature, the
subcommand would be completely omitted from the CLI parser, instead of
using the stub.

Furthermore, the `SelfUpdate` struct in `src/cli/self_update_stub.rs`
did not derive the `clap::Parser` trait, nor did it have an asynchronous
`run` method, which is required by the subcommand runner in
`src/cli/mod.rs`.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 16, 2026

Greptile Summary

This PR fixes a bug where the self-update subcommand was entirely absent from the CLI when compiled without the self_update Cargo feature. It removes the #[cfg(feature = "self_update")] gates from src/cli/mod.rs and brings the stub in self_update_stub.rs up to the interface required by the command dispatcher — adding clap::Args derivation, matching field definitions, and an async run() method that displays any configured upgrade instructions then bails with a clear message.

Confidence Score: 5/5

Safe to merge — the fix is minimal, correct, and the stub now satisfies the full subcommand interface required by the dispatcher.

Both changed files are clean: the cfg gates are correctly removed from mod.rs, and the stub now derives clap::Args with fields that exactly mirror the real implementation, plus a conformant async run() returning a clear error. No logic, data, or security issues were found.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/mod.rs Removes two #[cfg(feature = "self_update")] gates so the stub variant is included in Commands enum and its run() dispatch arm is always compiled — straightforward and correct.
src/cli/self_update_stub.rs Adds clap::Args derivation with fields matching the real implementation, and a conformant async run() that surfaces upgrade instructions then returns a clear build-time error; no issues found.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["User runs: mise self-update"] --> B{"Cargo feature\nself_update enabled?"}
    B -->|"Yes\n(src/cli/self_update.rs)"| C{is_available?}
    B -->|"No\n(src/cli/self_update_stub.rs)"| D["Show upgrade instructions\n(if MISE_SELF_UPDATE_INSTRUCTIONS set)"]
    C -->|"true OR --force"| E["Download & install update\nfrom GitHub Releases"]
    C -->|"false AND no --force"| F["Show upgrade instructions\nbail: installed via package manager"]
    D --> G["bail: disabled at build time"]
    E --> H["Updated successfully\n(optionally update plugins)"]
Loading

Reviews (4): Last reviewed commit: "refactor(self-update): mirror all fields..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request makes the self-update command always available in the CLI by removing conditional compilation flags. A stub implementation is introduced to handle cases where the feature is disabled at build time, providing users with instructions and a clear error message. Feedback includes improving consistency with the main implementation by using clap::Args and Default for the stub struct, as well as using crate::Result for the return type.

Comment thread src/cli/self_update_stub.rs Outdated
Comment thread src/cli/self_update_stub.rs Outdated
salim-b and others added 2 commits April 16, 2026 17:42
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jdx
Copy link
Copy Markdown
Owner

jdx commented Apr 16, 2026

Looks good overall, but I think the stub SelfUpdate struct should also mirror the fields from the real one (-f/--force, -y/--yes, --version). Otherwise on a no-self_update build, mise self-update -y will fail with a clap parse error for an unknown flag instead of hitting your nice "disabled at build time" bail. Ignoring the values in the stub's run() is fine — we just want the argument parsing to succeed so users get the helpful message.

This comment was generated by an AI coding assistant.

so valid subcommand flags are parsed correctly at run time even when
compiled with the `self_update` feature disabled
@jdx jdx merged commit 41a28b2 into jdx:main Apr 16, 2026
34 checks passed
@salim-b salim-b deleted the fix-self-update-stub branch April 16, 2026 16:47
mise-en-dev added a commit that referenced this pull request Apr 17, 2026
### 🚀 Features

- **(registry)** add .perl-version support for perl by @ergofriend in
[#9102](#9102)
- **(task)** add Tera template support for inline table run tasks by
@iamkroot in [#9079](#9079)

### 🐛 Bug Fixes

- **(env)** use runtime symlink paths for fuzzy versions by @jdx in
[#9143](#9143)
- **(github)** use full token resolution chain for attestation
verification by @jdx in [#9154](#9154)
- **(go)** Remove install-time version override for subpath packages by
@c22 in [#9135](#9135)
- **(npm)** respect install_before when resolving dist-tag versions by
@webkaz in [#9145](#9145)
- **(self-update)** ensure subcommand exists by @salim-b in
[#9144](#9144)
- **(task)** show available tasks when run target missing by @jdx in
[#9141](#9141)
- **(task)** forward task help args and add raw_args by @jdx in
[#9118](#9118)
- **(task)** remove red/yellow from task prefix colors by
@lechuckcaptain in [#8782](#8782)
- **(task)** merge TOML task block into same-named file task and surface
resolved dir by @jdx in [#9147](#9147)
- **(toolset)** round-trip serialized tool options by @atharvasingh7007
in [#9124](#9124)
- **(vfox)** fallback to absolute bin path if env_keys not set by
@80avin in [#9151](#9151)

### 📚 Documentation

- make agent guide wording generic by @jdx in
[#9142](#9142)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:deb docker digest to e019cb9 by @renovate[bot]
in [#9160](#9160)
- update ghcr.io/jdx/mise:copr docker digest to 8d25608 by
@renovate[bot] in [#9159](#9159)
- update ghcr.io/jdx/mise:rpm docker digest to 22e52da by @renovate[bot]
in [#9161](#9161)
- update ghcr.io/jdx/mise:alpine docker digest to a3da97c by
@renovate[bot] in [#9158](#9158)
- update rust docker digest to 4a2ef38 by @renovate[bot] in
[#9162](#9162)
- update ubuntu:24.04 docker digest to c4a8d55 by @renovate[bot] in
[#9164](#9164)
- update rust crate aws-lc-rs to v1.16.3 by @renovate[bot] in
[#9165](#9165)
- update ubuntu docker tag to resolute-20260413 by @renovate[bot] in
[#9169](#9169)
- update rust crate clap to v4.6.1 by @renovate[bot] in
[#9166](#9166)
- update taiki-e/install-action digest to a2352fc by @renovate[bot] in
[#9163](#9163)
- update rust crate ctor to 0.10 by @renovate[bot] in
[#9170](#9170)
- update rust crate tokio to v1.52.1 by @renovate[bot] in
[#9167](#9167)
- update rust crate rmcp-macros to 0.17 by @renovate[bot] in
[#9173](#9173)
- update rust crate signal-hook to 0.4 by @renovate[bot] in
[#9177](#9177)
- update rust crate zipsign-api to 0.2 by @renovate[bot] in
[#9180](#9180)
- update rust crate toml_edit to 0.25 by @renovate[bot] in
[#9179](#9179)
- update rust crate strum to 0.28 by @renovate[bot] in
[#9178](#9178)

### 📦 Registry

- add ibmcloud by @dnwe in
[#9139](#9139)
- add rush by @jdx in [#9146](#9146)

### New Contributors

- @80avin made their first contribution in
[#9151](#9151)
- @atharvasingh7007 made their first contribution in
[#9124](#9124)
- @lechuckcaptain made their first contribution in
[#8782](#8782)
- @ergofriend made their first contribution in
[#9102](#9102)
- @dnwe made their first contribution in
[#9139](#9139)

## 📦 Aqua Registry Updates

#### New Packages (3)

-
[`controlplaneio-fluxcd/flux-operator`](https://github.com/controlplaneio-fluxcd/flux-operator)
-
[`dependency-check/DependencyCheck`](https://github.com/dependency-check/DependencyCheck)
- [`kiro.dev/kiro-cli`](https://github.com/kiro.dev/kiro-cli)

#### Updated Packages (2)

-
[`jreleaser/jreleaser/standalone`](https://github.com/jreleaser/jreleaser/standalone)
- [`sigstore/cosign`](https://github.com/sigstore/cosign)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants