Skip to content

feat: Improve error for install with specific version#190

Open
kenoss wants to merge 3 commits into
chawyehsu:mainfrom
kenoss:better-error-for-install
Open

feat: Improve error for install with specific version#190
kenoss wants to merge 3 commits into
chawyehsu:mainfrom
kenoss:better-error-for-install

Conversation

@kenoss

@kenoss kenoss commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Option 1 of #189


Before this patch, moonup install <specific-version> fails with an simple error:

$ moonup install 0.9.3
No toolchain available for requested spec '0.9.3'

This patch improves the error, showing available versions near to the given version:

$ moonup install 0.9.3
  x no release available for requested spec: 0.9.3. hint: e.g. 0.9.3+08f337e2c is available.

Note that I'm using aarch64 Linux and I need tweaks to run tests. I checked that the test passes in my environment, but it might fail.

Before this patch, `moonup install <specific-version>` fails with an
simple error:

```
$ moonup install 0.9.3
No toolchain available for requested spec '0.9.3'
```

This patch improves the error, showing available versions near to the
given version:

```
$ moonup install 0.9.3
  x no release available for requested spec: 0.9.3. hint: e.g. 0.9.3+08f337e2c is available.
```
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 050527aa-ef79-4cc5-a7ea-1ca708ea5d70

📥 Commits

Reviewing files that changed from the base of the PR and between 83d9a87 and 7b84527.

⛔ Files ignored due to path filters (1)
  • tests/e2e/snapshots/test__e2e__flow__moonup_install_specific_version_unavailable_mock.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • src/toolchain/index.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/toolchain/index.rs

Summary by CodeRabbit

  • Bug Fixes
    • Improved toolchain install and update error handling so unavailable releases/versions return clear, actionable messages instead of abrupt failures.
    • For requested toolchain versions, the app now performs exact matching and—when no exact match exists—suggests nearby available versions.
  • New Features
    • Enhanced version resolution logic for install/update flows, including improved handling of nightly and release requests.
  • Tests
    • Added an additional end-to-end snapshot assertion for installing an unavailable specific version using the mocked dist server.

Walkthrough

This PR changes build_installrecipe to return InstallRecipe directly, adds error reporting for missing supported releases, and updates the install/update commands to propagate those errors. The e2e flow adds a snapshot for an unavailable specific-version install. regex was moved into the main dependencies table.

Changes

Toolchain recipe errors

Layer / File(s) Summary
Recipe return type and missing-host errors
src/toolchain/index.rs
build_installrecipe returns InstallRecipe directly, and unsupported Bleeding/Latest/Nightly specs now return miette errors instead of None.
Version parsing and hinting
Cargo.toml, src/toolchain/index.rs
regex moves into the main dependency table, and version-based recipe lookup now parses supported releases, sorts them, binary-searches exact matches, and includes nearby-version hints when no match is found.
CLI propagation and install snapshot
src/cli/install.rs, src/cli/update.rs, tests/e2e/flow.rs
moonup install and moonup update now propagate build_installrecipe failures, and the e2e flow adds a snapshot for installing version 0.1 against the mocked dist server.

Possibly related issues

  • chawyehsu/moonup#189 — The PR updates build_installrecipe, moonup install, and the version-selection path to emit clearer unavailable-version errors and adds a snapshot for that specific-version case.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a0f5263b-984c-4536-af05-4ea61bfaee07

📥 Commits

Reviewing files that changed from the base of the PR and between 1af68b2 and 83d9a87.

⛔ Files ignored due to path filters (1)
  • tests/e2e/snapshots/test__e2e__flow__moonup_install_specific_version_unavailable_mock.snap is excluded by !**/*.snap
📒 Files selected for processing (5)
  • Cargo.toml
  • src/cli/install.rs
  • src/cli/update.rs
  • src/toolchain/index.rs
  • tests/e2e/flow.rs

Comment thread src/toolchain/index.rs
Comment thread tests/e2e/flow.rs
@chawyehsu

Copy link
Copy Markdown
Owner

I'd love to place the hint to a new line. This way, when we add other hints later, we can keep all hints in the same format.

$ moonup install 0.9.3
No release available for requested spec '0.9.3'

Hint: 0.9.3+08f337e2c is available

@kenoss

kenoss commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Updated. Two versions:

commit 916de59 (with \n\n)

$ cargo run --bin moonup -- install 0.9.3
  x No release available for requested spec: 0.9.3.
  |
  | Hint: 0.9.3+08f337e2c is available.

commit 7b84527 (with MietteDiagnostic::with_help())

$ cargo run --bin moonup -- install 0.9.3
  x No release available for requested spec: 0.9.3.
  help: 0.9.2+bbe2b338f and 0.9.3+08f337e2c are available.

Note that there is no hint field in miette::Diagnostic and we need to use help. We can use custom handlers to modify format.

Which one is better? Also, let me know if we use squash for commit.


I'll fix #191 first as the test for aarch64 is failing.

@stage-review

stage-review Bot commented Jun 29, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 3 individual chapters for you:

Title
1 Promote regex to a core dependency
2 Enhance version resolution with helpful error hints
3 Other changes
Open in Stage

Chapters generated by Stage for commit 7b84527 on Jun 29, 2026 3:23am UTC.

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