Skip to content
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

feat: update toolchain on lake update #5684

Merged
merged 25 commits into from
Nov 4, 2024

Conversation

tydeu
Copy link
Member

@tydeu tydeu commented Oct 12, 2024

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.

@tydeu tydeu marked this pull request as draft October 12, 2024 22:55
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Oct 12, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 12, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 12, 2024
@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Oct 13, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Oct 13, 2024

Mathlib CI status (docs):

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 16, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 16, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 16, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 16, 2024
@tydeu tydeu force-pushed the lake/update-toolchain branch from 7af30ad to 33cf999 Compare October 16, 2024 05:30
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 16, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 16, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 17, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 19, 2024
@tydeu tydeu marked this pull request as ready for review October 19, 2024 02:26
@tydeu tydeu added the will-merge-soon …unless someone speaks up label Oct 19, 2024
@tydeu tydeu force-pushed the lake/update-toolchain branch from f6b5758 to 5e8b29e Compare October 19, 2024 17:40
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 19, 2024
@tydeu
Copy link
Member Author

tydeu commented Oct 19, 2024

!bench

@leanprover-community-bot leanprover-community-bot removed the builds-mathlib CI has verified that Mathlib builds against this PR label Oct 19, 2024
@tydeu tydeu force-pushed the lake/update-toolchain branch from 3492a53 to 51bf3ea Compare October 30, 2024 12:59
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 30, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 30, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 1, 2024
grunweg pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 2, 2024
Changes `scripts/mk_all` to run `loadWorkspace` using Lake's `toBaseIO` utility. In addition to being a bit cleaner, this adaption will also be necessary once leanprover/lean4#5684 lands.
@tydeu tydeu added this pull request to the merge queue Nov 4, 2024
Merged via the queue into leanprover:master with commit 99070bf Nov 4, 2024
14 checks passed
@tydeu tydeu deleted the lake/update-toolchain branch November 4, 2024 15:05
JovanGerb pushed a commit to JovanGerb/lean4 that referenced this pull request Nov 4, 2024
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.**
kim-em pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 5, 2024
Adaption for leanprover/lean4#5684. Lake's `--lean` option has been
removed, so this instead environment variables (`LEAN` with
`LAKE_OVERRIDE_LEAN`) to configure the benchmark's fake Lean root.
@Kha Kha added release-ci Enable all CI checks for a PR, like is done for releases and removed release-ci Enable all CI checks for a PR, like is done for releases labels Nov 6, 2024
TwoFX pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 13, 2024
Adaption for leanprover/lean4#5684. Lake's `--lean` option has been
removed, so this instead environment variables (`LEAN` with
`LAKE_OVERRIDE_LEAN`) to configure the benchmark's fake Lean root.
nomeata pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 13, 2024
Adaption for leanprover/lean4#5684. Lake's `--lean` option has been
removed, so this instead environment variables (`LEAN` with
`LAKE_OVERRIDE_LEAN`) to configure the benchmark's fake Lean root.
nomeata pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 14, 2024
Adaption for leanprover/lean4#5684. Lake's `--lean` option has been
removed, so this instead environment variables (`LEAN` with
`LAKE_OVERRIDE_LEAN`) to configure the benchmark's fake Lean root.
nomeata pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 14, 2024
Adaption for leanprover/lean4#5684. Lake's `--lean` option has been
removed, so this instead environment variables (`LEAN` with
`LAKE_OVERRIDE_LEAN`) to configure the benchmark's fake Lean root.
kim-em pushed a commit that referenced this pull request Nov 29, 2024
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.

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).

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.**
kim-em added a commit to leanprover-community/mathlib4 that referenced this pull request Dec 1, 2024
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Dec 1, 2024
leanprover/lean4#5684 (which landed in v4.14.0-rc3) has removed the `--lean` flag for `lake`, indicating that we should use the `LEAN` environment variable instead.
kim-em added a commit to leanprover-community/mathlib4 that referenced this pull request Dec 1, 2024
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Dec 1, 2024
@kim-em kim-em added the changelog-lake Lake label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR changelog-lake Lake toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
6 participants