Skip to content

feat(lockfiles): borrow tool versions from the user's own mise installs - #6

Merged
sweepies merged 5 commits into
mainfrom
tools/seed-from-user-mise
Oct 21, 2026
Merged

sweepies merged 5 commits into
mainfrom
tools/seed-from-user-mise

Conversation

@sweepies

@sweepies sweepies commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Local runs hard-link a tool version the user already has in their own mise (Node, Go, Bun, aube, Yarn, uv, Terraform) into the Count's tool store instead of downloading it.

  • The store's links are its own: pruning and clearing unproven installs remove only them, never the user's install.
  • Each version is borrowed at most once (patchula-seeded.json); a failure falls back to a normal mise install.
  • Python, Ruby, PHP and .NET are always installed fresh (their installs embed their path or share one root); a version that resolves outside its tool's directory is never copied.
  • Hard links need one filesystem; otherwise it falls back to downloading. The server never borrows.
  • Also quiets the "unproven tool install was not removed … is not installed" warning on a fresh store.

Measured on a fresh store with patchula tools install: 35 s with borrowing, against 68 s without, on a fast connection; every borrowed tool ran from the store.

🤖 Generated with Claude Code


Devin Review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 0f10ea0 Commit Preview URL

Branch Preview URL
Oct 21 2026, 10:14 PM

@deepsource-io

deepsource-io Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in e345380...0f10ea0 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Rust Oct 21, 2026 10:14p.m. Review ↗
JavaScript Oct 21, 2026 10:14p.m. Review ↗
Shell Oct 21, 2026 10:14p.m. Review ↗
Secrets Oct 21, 2026 10:14p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread crates/update/src/lockfiles/tools.rs Outdated
Comment on lines +141 to +144
match backend.is_file() && !to.join(".mise.backend.toml").exists() {
true => std::fs::copy(backend, to.join(".mise.backend.toml")).map(drop),
false => Ok(()),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using `match` over a boolean condition, consider using an `if`/`else` expression


Matching over a boolean expression is less readable than using an if-else block.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 3 potential issues.

Devin Review

Comment on lines +146 to +150
match linked {
Ok(()) => tracing::info!(tool = %spec, "seeded from the user's mise install"),
Err(error) => {
let _ = std::fs::remove_dir_all(to.join(version));
tracing::debug!(tool = %spec, %error, "not seeded; mise will install it");

@devin-ai-integration devin-ai-integration Bot Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Borrowed version replaces an in-progress install

If mise creates an empty version directory after seed checks it, rename replaces that directory on Unix. The running install can then write into the borrowed tree instead of its own.

Learn more

The destination-exists check at seed happens before staging. On Unix, renaming a directory over an existing empty directory succeeds; it does not act as an exclusive create. A concurrent mise install can create an empty destination after that check, and the seeder can replace it before mise writes its files. The borrowed tree is hard-linked to the user's files, so mixing writes from the concurrent install with that tree also risks modifying the user's installation.

Example: Process A creates installs/node/24.21.0 and pauses before extracting Node. Process B's earlier check saw no destination and renames its completed staging directory over A's empty directory. When A resumes, its writes target B's borrowed installation instead of a fresh one.

Recommended fix: Publish with a no-replace operation rather than ordinary directory rename, and treat an existing destination as another install's responsibility. Ensure staging cleanup only removes this seeder's own directory.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread crates/update/src/lockfiles/tools.rs Resolved
Comment thread docs/guide/lockfiles.md Resolved
devin-ai-integration[bot]

This comment was marked as resolved.

Comment thread crates/cli/src/main.rs Outdated
Ok(match app.recheck {
Some(cli::Recheck::Now) => patchula_engine::Recheck::Now,
Some(cli::Recheck::NextRun) => patchula_engine::Recheck::NextRun,
None if run => match std::env::var("PATCHULA_RECHECK").as_deref() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using `std::env::var` with a string literal


Calls to the std::env functions that use string literals instead of a
static strings can lead to bugs due to spelling errors.

Comment thread crates/cli/src/main.rs Outdated
/// Docker Hub credentials, when both variables are set.
fn dockerhub_credentials() -> Result<Option<(String, String)>, (u8, miette::Report)> {
match (
std::env::var("PATCHULA_DOCKERHUB_USERNAME").ok(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using `std::env::var` with a string literal


Calls to the std::env functions that use string literals instead of a
static strings can lead to bugs due to spelling errors.

Comment thread crates/cli/src/main.rs Outdated
fn dockerhub_credentials() -> Result<Option<(String, String)>, (u8, miette::Report)> {
match (
std::env::var("PATCHULA_DOCKERHUB_USERNAME").ok(),
std::env::var("PATCHULA_DOCKERHUB_TOKEN").ok(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using `std::env::var` with a string literal


Calls to the std::env functions that use string literals instead of a
static strings can lead to bugs due to spelling errors.

sweepies and others added 5 commits October 21, 2026 22:10
A local run hard-links a version the user already has (Node, Go, Bun, aube,
Yarn, uv, Terraform) into the tool store instead of downloading it. The
store's links are its own, so pruning and clearing unproven installs never
touch the user's. Each version is borrowed once; a failure falls back to a
normal install. Versions in a root shared with others, like .NET's, are not
copied. The server never borrows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ut of the install

Each run builds its copy in a staging directory of its own and renames it
into place, so two runs borrowing one version can no longer remove each
other's copy. Symlinks must resolve inside the version directory; absolute
ones (mise's .mise-bins) are pointed at the copy. The installation page now
mentions borrowing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
run dispatches to config, TUI and tools handlers, and report takes its HTTP
options, recheck wording and Docker Hub credentials from small helpers.
No behaviour changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e the CLI's environment variables

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sweepies
sweepies force-pushed the tools/seed-from-user-mise branch from 332b2a0 to 0f10ea0 Compare October 21, 2026 22:13
@sweepies
sweepies merged commit f8c2e90 into main Oct 21, 2026
14 checks passed
@sweepies
sweepies deleted the tools/seed-from-user-mise branch October 21, 2026 22:22
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.

1 participant