mill icon indicating copy to clipboard operation
mill copied to clipboard

Move BSP out dir to a different folder

Open lihaoyi opened this issue 10 months ago • 6 comments

Now that we're using Scala 3 and the IntelliJ compile server is on by default, I've been seeing intermittent errors that seem to suggest multiple compilers stomping over each's files on disks

lihaoyi avatar Feb 04 '25 14:02 lihaoyi

So, you suggesting to no longer shared any build cache between CLI and IDE? A lot of development efforts went into sharing both, but sometimes with questionable success (For example: shared compile results while keeping IDE-dedicated resuls like semanticdb files separate). We should present the pros and cons. And probable make this an easy user-selectable option instead of a hard-coded choice.

Personally, I have not much use of shared build caches (in its current state). When using GenIdea, we also don't share compiler build output. When I need artifacts or other build targets, I always go to the CLI. IDE is just for editing, sometimes testing (when writing the test or the code under test).

lefou avatar Feb 04 '25 17:02 lefou

Beside avoiding a whole class of possible issues, we also could avoid the global lock by making it out-dir specific.

lefou avatar Feb 04 '25 17:02 lefou

Instead of using a different out-dir, we could just change all those bspXXX targets that return an UnresolvedPath, since they potentially violate the T.dest contract, to only read but not write files in foreign T.dest paths. Instead of peaking into the T.dest of their companion non-bsp tasks, they should just use their own T.dest.

As a consequence, potential out-of-sync tasks that return an UnresolvedPath aren't shared between BSP and CLI, but all other tasks like source generators or practically everything that is not handled by BSP specifically, can be shared as before, as Mill takes care of their integrity.

lefou avatar Feb 04 '25 17:02 lefou

I think having separate out/ folders and separate Mill processes would be the simplest thing here. IIRC that's also what SBT does (or can be configured to do?) to avoid the same class of problem.

We could definitely tweak the BSP side to try and make the interference go away, but I'm not familiar enough with our BSP integration to knwo for sure if it's feasible

lihaoyi avatar Feb 05 '25 05:02 lihaoyi

According to https://blog.pierre-ricadat.com/scala-3-migration-report-from-the-field, Intellij/SBT has a co fig use separate compiler output paths that does this

lihaoyi avatar Feb 07 '25 01:02 lihaoyi

A Manual workaround to unblock intellij is to set change Settings / Languages & Frameworks / Scala / Editor / Error Highlighting / Scala3 from Compiler to Built-in, which makes IntelliJ not make so many requests to BSP resulting in less blocking

lihaoyi avatar Jun 15 '25 01:06 lihaoyi

Taking this on.

Will make it configurable via mill frontmatter.

arturaz avatar Aug 11 '25 13:08 arturaz