Skip to content

feat(install): add per-tool install_before option#8842

Merged
jdx merged 1 commit intojdx:mainfrom
sargunv-headway:feat/per-tool-install-before
Apr 2, 2026
Merged

feat(install): add per-tool install_before option#8842
jdx merged 1 commit intojdx:mainfrom
sargunv-headway:feat/per-tool-install-before

Conversation

@sargunv-headway
Copy link
Copy Markdown
Contributor

@sargunv-headway sargunv-headway commented Apr 1, 2026

Adds per-tool install_before override as mentioned in #8711.

[settings]
install_before = "7d"  # default for all tools

[tools.trivy]
version = "latest"
install_before = "1d"  # override for this tool

Precedence: --before CLI flag > per-tool install_before > global install_before setting.

Questions for reviewer

  • Added install_before to EPHEMERAL_OPT_KEYS since it only affects version resolution, not tool identity. Should it be persisted instead?
  • Moved the global install_before fallback from each CLI command into ToolRequest::resolve to support the three-tier precedence. Is there a better place for this?

This PR was created with Claude Code.

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 introduces per-tool install_before settings, allowing users to override global configurations for specific tools. It establishes a precedence hierarchy where the CLI --before flag takes priority over per-tool settings, which in turn override global settings. The implementation includes documentation updates, new E2E tests, and a refactor of the resolution logic. A review comment suggests simplifying the before_date resolution logic in src/toolset/tool_request.rs to improve readability and reduce unnecessary cloning.

Comment thread src/toolset/tool_request.rs Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 1, 2026

Greptile Summary

This PR introduces a per-tool install_before option in mise.toml, allowing users to override the global install_before setting on a per-tool basis. The precedence is: --before CLI flag > per-tool install_before > global install_before setting.

Key changes:

  • ToolRequest::resolve() now owns the full three-tier precedence logic. The global Settings::get().install_before fallback was moved here from each CLI command, and the new per-tool lookup (self.options().get("install_before")) is inserted between the CLI and global tiers.
  • CLI commands (install, upgrade, use) each have their get_before_date() trimmed to return only the CLI --before flag value; the settings fallback is no longer duplicated across all three.
  • EPHEMERAL_OPT_KEYS gains "install_before" so the option is not persisted to the lockfile/manifest, which is consistent with it affecting only version resolution and not tool identity.
  • E2e tests cover all three tiers of the precedence chain using jq as the test tool.
  • Documentation in both tips-and-tricks.md and settings.toml is updated with an example and precedence note.

The refactor is clean and the logic is easy to follow. As an implicit side-effect, any caller of ToolRequest::resolve() that previously did not go through a CLI get_before_date() (e.g. is_installed()) will now also apply per-tool and global install_before settings. This is semantically correct — if a user has configured a date window for a tool, "is this tool installed?" should resolve with the same window — but it is worth noting as a behaviour change beyond the pure CLI paths.

Confidence Score: 5/5

  • Safe to merge; no P0/P1 issues found and prior review concerns have all been addressed or are tracked in existing threads.
  • All remaining observations are P2 (style/cleanup) and have already been captured in prior review threads. The core logic is correct, the precedence chain is well-tested, and the refactor properly centralises the settings fallback in ToolRequest::resolve() without introducing regressions.
  • No files require special attention. The minor missing rm -f mise.toml cleanup in e2e/cli/test_install_before is already tracked in a prior thread.

Important Files Changed

Filename Overview
src/toolset/tool_request.rs Adds three-tier before_date precedence logic (CLI > per-tool > global) at the top of ToolRequest::resolve(); clean and correctly ordered conditional.
src/toolset/tool_version_options.rs Adds "install_before" to EPHEMERAL_OPT_KEYS, correctly preventing it from being persisted in the lockfile or manifest since it only affects version resolution, not tool identity.
src/cli/install.rs Removes global settings fallback from get_before_date(); now returns only the CLI --before flag, delegating settings lookup to ToolRequest::resolve().
src/cli/upgrade.rs Same refactor as install.rs: strips global settings fallback from get_before_date() and removes the now-unused Settings import.
src/cli/use.rs Same refactor as install.rs and upgrade.rs; get_before_date() now returns only the CLI flag value.
e2e/cli/test_install_before Adds three e2e test cases covering all three tiers of the precedence (per-tool newer than global, per-tool older than global, CLI flag overrides per-tool); the final block is missing a rm -f mise.toml cleanup (already noted in prior thread).
docs/tips-and-tricks.md Adds a per-tool install_before usage example and the three-tier precedence note; documentation is accurate and matches the implementation.
settings.toml Updates the install_before setting description to mention the per-tool override and adds a TOML example snippet.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["ToolRequest::resolve(config, opts)"] --> B{opts.before_date\nis Some?}
    B -- Yes --> E["Use opts as-is\n(CLI --before flag wins)"]
    B -- No --> C{per-tool\ninstall_before\nin options?}
    C -- Yes --> F["Clone opts,\nset before_date\nfrom per-tool value"]
    C -- No --> D{global\nSettings::install_before\nis Some?}
    D -- Yes --> G["Clone opts,\nset before_date\nfrom global setting"]
    D -- No --> H["Use opts as-is\n(no date filter)"]
    E --> Z["ToolVersion::resolve(config, self, opts)"]
    F --> Z
    G --> Z
    H --> Z
Loading

Reviews (2): Last reviewed commit: "feat(install): add per-tool install_befo..." | Re-trigger Greptile

Comment thread src/toolset/tool_request.rs Outdated
Comment thread src/toolset/tool_request.rs
Comment thread e2e/cli/test_install_before
Allows overriding the global install_before setting on a per-tool basis:

```toml
[tools.trivy]
version = "latest"
install_before = "1d"
```

Precedence: --before CLI flag > per-tool install_before > global setting.

Refs: jdx#8711

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sargunv-headway sargunv-headway force-pushed the feat/per-tool-install-before branch from baae061 to f2609d0 Compare April 1, 2026 21:38
@jdx jdx merged commit c552bf3 into jdx:main Apr 2, 2026
35 checks passed
mise-en-dev added a commit that referenced this pull request Apr 2, 2026
### 🚀 Features

- **(install)** add per-tool install_before option by @sargunv-headway
in [#8842](#8842)

### 🐛 Bug Fixes

- **(cli)** respect `-q` flag in `mise prepare` command by @Marukome0743
in [#8792](#8792)
- fall back to compile-time musl detection when no system linker found
by @davireis in [#8825](#8825)

### 📚 Documentation

- fix GitHub capitalization in Alpine docs by @Rohan5commit in
[#8844](#8844)

### 📦 Registry

- add dbt-fusion
([aqua:getdbt.com/dbt-fusion](https://github.com/getdbt.com/dbt-fusion))
by @ryan-pip in [#8837](#8837)

### New Contributors

- @Marukome0743 made their first contribution in
[#8792](#8792)
- @sargunv-headway made their first contribution in
[#8842](#8842)
- @Rohan5commit made their first contribution in
[#8844](#8844)
- @ryan-pip made their first contribution in
[#8837](#8837)
- @rndmh3ro made their first contribution in
[#8839](#8839)

## 📦 Aqua Registry Updates

#### New Packages (1)

- [`azu/dockerfile-pin`](https://github.com/azu/dockerfile-pin)

#### Updated Packages (4)

- [`anthropics/claude-code`](https://github.com/anthropics/claude-code)
- [`dandavison/delta`](https://github.com/dandavison/delta)
- [`goreleaser/goreleaser`](https://github.com/goreleaser/goreleaser)
- [`zellij-org/zellij`](https://github.com/zellij-org/zellij)
@sargunv-headway sargunv-headway deleted the feat/per-tool-install-before branch April 2, 2026 17:34
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