Open david-christiansen opened 2 months ago
Can we also lift this restriction? It is not very intuitive from the user's perspective, also as evidenced by the discussion.
I think that it's reasonable for each library to have its own root(s), disjoint from all others. Otherwise, we could encounter large coordination problems, because adding a module to a library could break some other library that placed it in the same location. I don't think that's unintuitive.
I don't see how there are large coordination problems if the two libraries in question are in the same package, as in your example. The coordination problem only arises if these are libraries under different maintainers. But even then, this seems like an issue for lake to be dealing with, not lean.
I think that it's reasonable for each library to have its own root(s), disjoint from all others.
Moreover, this is not just about library roots being distinct: if package foo
has library 1 at Foo.Lib1.*
and library 2 at Foo.Lib2.*
then this is still disallowed, because both libraries have the same root Foo
, which is named after the package foo
. To me this seems like (1) not a collision and (2) a perfectly reasonable thing for the foo
package to do, and banning it makes no sense to me. In fact, it creates a perverse incentive where package foo
now has to take multiple top level roots like Lib1.*
and Lib2.*
which are more likely to conflict with libraries from other packages because they lack the Foo
prefix. Perhaps we would say that they should have been named FooLib1.*
and FooLib2.*
but in practice that's not how libraries are being named currently.
if package foo has library 1 at Foo.Lib1. and library 2 at Foo.Lib2. then this is still disallowed
I don't think it is?
Description
Lake allows the definition of library configurations that cannot reliably work because their roots overlap.
In particular, I can define the following configurations with no warnings or errors in the Lakefile:
Running
lake build
results in an error that a file can't be found:Setting the second root to
A.C
allows a successful build.When one root subsumes another, the results of
import
become difficult to predict.Context
This came up during out-of-band discussion surrounding #4962.
Steps to Reproduce
There's a few related issues here that I think are all symptoms of the same missing error message.
To reproduce the issue of two libraries having the same root:
Lib1/
, runlake build
To reproduce the issue of one subsuming another:
Lib2/
, runlake build
A.D
from libraryab
being used (seeLib2/Other.lean
to verify)Expected behavior:
In both cases, I'd expect an error message in my editor when working on
Lib1/lakefile.lean
that the provided module root sets conflict with each other. I'd also expect that Lake would provide an error message when I attempt to build it.At elaboration time, I'd expect the definition of library
AC
to have a message like:AC's root 'A' conflict's with AB's root 'A'.
When running a build, assuming the elaboration-time error of the Lake configuration was not fatal, I'd expect something like:
or
Actual behavior:
When the roots are identical, there are confusing messages about "No such file". When they are not, but one subsumes the other, the results of importing modules from the package's libraries are difficult to predict.
Versions
"4.12.0-nightly-2024-08-16"
macOS 14.6.1
Impact
Add :+1: to issues you consider important. If others are impacted by this issue, please ask them to add :+1: to it.