-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: lake update
should update the lean-toolchain
#2752
Comments
About the second option, is it always true that a later toolchain can compile code written for an earlier toolchain? |
No, but nor is the reverse true, and if you run |
Per the discussion on the thread, why can't this be implemented on the vscode extension as a behaviour specific to projects where mathlib is a non-inherited dependency and there are no others? Eventually lake would have some versioning for dependencies that makes this problem go away right? |
@Shreyas4991 Dependency versioning is very difficult in Lean. I think it will be a long while before we have something like semantic versioning. This RFC strikes me as potentially a pretty good general solution for the short term. |
I agree with that. I am aware that dependency management is going to take a while. Which is why I was just wondering if this could be implemented as a vscode command called "update mathlib" as discussed in the thread. (Ref: the first message in the thread linked in my previous comment here). This is fundamentally a mathlib specific workflow request that can be accommodated in a vscode command. The gist of that thread is: A GUI panel for lake commands is already planned. It is feasible to add mathlib specific options. The people most likely to be unable to solve the issue with lake update are also likely to be uncomfortable with CLIs. So GUI commands that perform safe default actions might be a shorter fix. It would also address in a limited way, the concerns of others that lake is doing many things, including very mathlib specific ones. |
I don't agree with this at all. The problem as described will affect anyone who depends on a package that changes lean version. |
Then this could be part of the update command on vscode. My issue with the current RFC is that for any project with more than one non-inherited dependency (which we must not discount, just because it might be a fraction of current projects), it it not clear that it will work. As Mac points out, dependency management will take time. So, for however long this takes, we have no guarantees that such a project can be built with lake. Further, the 99% who do benefit from this are also likely to be mostly GUI users. If this RFC is implemented, options 1 and 2 seem to be the best, but option 1 can confuse CLI-averse users with its options. Implementing 2 or 3 as a GUI command on vscode hides the scary CLI stuff for those who don't like CLIs. This is also a temporary fix, so eventually the GUI button can be withdrawn/modified. EDIT: On second thoughts, if we do take the GUI route for option 2 or 3, then implementing option 1 in the lake CLI will be great for CLI users. |
My intended resolution to this RFC would be to check the
However, it is worth nothing that none of these solutions will fix the case where |
Overall, sounds good.
Is a total ordering necessary here? Isn't what we need a partial ordering with a least upper bound?
Could lake be decoupled from the toolchain and managed by elan? cargo version appears to be managed by rustup for example. Why is it currently bundled with the toolchain? |
It is managed by elan, the toolchain version is how it is managed. |
What I mean is whether we could decouple the two: Let elan manage lake separately from the rest of the toolchain. |
I'm happy with this compromise as long as the warning includes all the |
@Shreyas4991 We want Lake to be part of the toolchain, though. Otherwise, breaking changes would leave old Lake projects unbuildable. |
I have no opinions on this case, as I have not seen it happen. |
Why does it need this much information? If Lake has no clue, I doubt the user will either. In such a case, they will likely have do some manually checking across the packages for what changes were made and which one needs what. Or, if they just forgot to update their toolchain to specific version already in mind, a simple warning should be enough to make them remember. |
More specifically, I was thinking of a warning of the following form (if the dependencies are incomparable):
|
Lake has easy access to information that the user doesn't; the version of the toolchains that the dependencies were using before they ran
where this tells the user "oh, I probably want to paste |
@eric-wieser Fair enough. Minor note: in the situation for this warning, the workspace toolchain would not be updated. |
Indeed; the template was intended as inspiration for all the other "print a warning" options in your list, some of which I believe do involve an update. |
I think this can now be closed in favour of leanprover-community/mathlib4#7846 |
@semorrison That is just mathlib-specific. The goal for this issue is to provide a general solution toolchain updates as part of |
In particular, anyone using Std but not mathlib will still experience this issue |
There are other situations where a lean-toolchain sync would be important as well, such as adding new dependencies to the lakefile. Should this issue be generalized or should this be tracked separately? |
Updating |
Lake will now update a package's `lean-toolchain` file on `lake update` if it finds the package's direct dependencies use a newer compatible toolchain. To skip this step, use the `--keep-toolchain` CLI option. Closes #2582. Closes #2752. Closes #5615. ### Toolchain update details To determine "newest compatible" toolchain, Lake parses the toolchain listed in the packages' `lean-toolchain` files into four categories: release , nightly, PR, and other. For newness, release toolchains are compared by semantic version (e.g., `"v4.4.0" < "v4.8.0"` and `"v4.6.0-rc1" < "v4.6.0"`) and nightlies are compared by date (e.g., `"nightly-2024-01-10" < "nightly-2014-10-01"`). All other toolchain types and mixtures are incompatible. If there is not a single newest toolchain, Lake will print a warning and continue updating without changing the toolchain. If Lake does find a new toolchain, Lake updates the workspace's `lean-toolchain` file accordingly and restarts the update process on the new Lake. If Elan is detected, it will spawn the new Lake process via `elan run` with the same arguments Lake was initially run with. If Elan is missing, it will prompt the user to restart Lake manually and exit with a special error code (4). ### Other changes To implement this new logic, various other refactors were needed. Here are some key highlights: * Logs emitted during package and workspace loading are now eagerly printed. * The Elan executable used by Lake is now configurable by the `ELAN` environment variable. * The `--lean` CLI option was removed. Use the `LEAN` environment variable instead. * `Package.deps` / `Package.opaqueDeps` have been removed. Use `findPackage?` with a dependency's name instead. * The dependency resolver now uses a pure breadth-first traversal to resolve dependencies. It also resolves dependencies in reverse order, which is done for consistency with targets. Latter targets shadow earlier ones and latter dependencies take precedence over earlier ones. **These changes mean the order of dependencies in a Lake manifest will change after the first `lake update` on this version of Lake.**
Lake will now update a package's `lean-toolchain` file on `lake update` if it finds the package's direct dependencies use a newer compatible toolchain. To skip this step, use the `--keep-toolchain` CLI option. Closes leanprover#2582. Closes leanprover#2752. Closes leanprover#5615. ### Toolchain update details To determine "newest compatible" toolchain, Lake parses the toolchain listed in the packages' `lean-toolchain` files into four categories: release , nightly, PR, and other. For newness, release toolchains are compared by semantic version (e.g., `"v4.4.0" < "v4.8.0"` and `"v4.6.0-rc1" < "v4.6.0"`) and nightlies are compared by date (e.g., `"nightly-2024-01-10" < "nightly-2014-10-01"`). All other toolchain types and mixtures are incompatible. If there is not a single newest toolchain, Lake will print a warning and continue updating without changing the toolchain. If Lake does find a new toolchain, Lake updates the workspace's `lean-toolchain` file accordingly and restarts the update process on the new Lake. If Elan is detected, it will spawn the new Lake process via `elan run` with the same arguments Lake was initially run with. If Elan is missing, it will prompt the user to restart Lake manually and exit with a special error code (4). ### Other changes To implement this new logic, various other refactors were needed. Here are some key highlights: * Logs emitted during package and workspace loading are now eagerly printed. * The Elan executable used by Lake is now configurable by the `ELAN` environment variable. * The `--lean` CLI option was removed. Use the `LEAN` environment variable instead. * `Package.deps` / `Package.opaqueDeps` have been removed. Use `findPackage?` with a dependency's name instead. * The dependency resolver now uses a pure breadth-first traversal to resolve dependencies. It also resolves dependencies in reverse order, which is done for consistency with targets. Latter targets shadow earlier ones and latter dependencies take precedence over earlier ones. **These changes mean the order of dependencies in a Lake manifest will change after the first `lake update` on this version of Lake.**
Current behavior
lake update
updates allinherited: false
dependencies, even if doing so would move to a newer toolchain.It does not change the value in
lean-toolchain
, not does it emit any diagnostic to indicate that this might need doing manually.This frequently bites users of projects which depend on mathlib, as
lake update
gives them a mathlib version that does not compile with (or at least, has no cache for) their active toolchainExpected behavior
lake update
should attempt to match thelean-toolchain
of the new dependency versions. The design could be any of:inherited: false
dependencies. If there is just one entry in this set, use it. If there is more than one, prompt the user.inherited: false
dependencies. Attempt to pick the most recent of the options.tracks_toolchain
key to the manifest, to indicate precisely which dependency the toolchain should be tracked from. For many users, this would be set tomathlib4
.The text was updated successfully, but these errors were encountered: