Skip to content

Conversation

@lefou
Copy link
Member

@lefou lefou commented Oct 24, 2025

Another attempt to make Mill cache storage relocate-able.

The idea is to replace absolute paths with paths relative to pre-defined known root paths.

The current roots are:

  • $WORKSPACE - the project directory (where the top-level build.mill can be found.
  • $MILL_OUT - the Mill output directory used for caches and build-results
  • $HOME - the user home directory

More paths come to mind:

  • $CACHE_COURSIER - the coursier cache directory
  • $CACHE_IVY - the ivy cache directory
  • $CACHE_MAVEN - the Maven cache directory

Those are currently not directly accessible in the code base. Also, their typical storage locations are already relative to $HOME (e.g. $CACHE_COURSIER vs $HOME/.cache/coursier), hence I left them out for now.

One design choice I made for now, is to go with a fixed set of known roots. This means, all of those must be configured before PathRefs can be used and de-/serialized. The alternative would be to dynamically register roots, allowing PathRef to be used without this restriction.

Some refactoring was necessary to streamline the configuration flow of the $MILL_OUT path. Before, the out path was constructed in many different locations, sometimes with slightly different logic. This is of course a minefield, since we have many entry points (Mill CLI, Mill Daemon, Mill BSP, Test Suites, Integration tests, ...) where those where set up. So this PR relies heavily on our good programmatic test coverage.

Attempt to fix #3660

Superseded by #6031, which maps the dynamically, which seems to be the better approach.

@lefou lefou changed the title [WIP] Map known root paths in cach files [WIP] Map known root paths in cache files Oct 24, 2025
@lefou
Copy link
Member Author

lefou commented Oct 24, 2025

I don't know when and why we changed the output of MainModule.show from result as JSON to content of cache-json file, but it now means, show displays no longer absolute local paths but pseudo-paths with placeholders for $WORKSPACE,$MILL_OUT and $HOME.

@lefou
Copy link
Member Author

lefou commented Oct 24, 2025

I currently hold the current out path in PathRef.outPathOverride, as there is no other accessible place where this information is available reliably. IMHO, we should expose it via BuilCtx, next to BuildCtx.workspaceRoot, since this imformation might be useful at various places and user builds. Evavluator.currentEvaluator also has a outPath, but it's often not available, and we don't need a full evaluator for just a user-configured path info.

@lefou
Copy link
Member Author

lefou commented Oct 25, 2025

Incremental tests fail, but I have no clue why.

The incrementation zinc-compilation is working properly, but in case of a second compile run Mill should not run the compile task at all, due to caching. This is what's broken now, probably due to some hash changes, which I need to figure out. Most likely we somewhere mix hashes of the mapped and unmapped json data.

@lefou
Copy link
Member Author

lefou commented Oct 25, 2025

Found the issue. Fixed it by implementing PathRef.hashCode based on the encoded path value.

@lefou
Copy link
Member Author

lefou commented Oct 27, 2025

The RCP-server currently fails, due to the mapping not being optional. I started to prepare a fix introducing new types LocalPath and LocalPathRef, which might work but is rather invasive. Instead, I'd like to reassess the non-optional design in another attempt, first.

@lefou
Copy link
Member Author

lefou commented Oct 29, 2025

Closing in favor of #6031

@lefou lefou closed this Oct 29, 2025
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.

Make out/ folder contents (more) reproducible and filesystem layout agnostic

1 participant