Skip to content

Reproducible instructions for installing and building Mathlib4 #73

@brando90

Description

@brando90

Issue: PyPantograph Fails to Read Mathlib.olean After Compilation

Summary

After following the recommended steps to set up Mathlib4 and integrate it with PyPantograph, I encountered the following error when trying to use Mathlib with PyPantograph:

AssertionError: Server failed to emit ready signal: uncaught exception: failed to read file '././.lake/build/lib/Mathlib.olean', invalid header
; Maybe the project needs to be rebuilt

Additionally, attempting to use lean directly with Mathlib also results in:

Test.lean:1:0: error: unknown module prefix 'Mathlib'
No directory 'Mathlib' or file 'Mathlib.olean' in the search path entries:
/lfs/skampere1/0/brando9/.elan/toolchains/leanprover--lean4---v4.16.0-rc2/lib/lean

Environment Information

  • Lean Version: 4.16.0-rc2

Steps to Reproduce

1. Cloned Mathlib4

cd ~
git clone https://github.com/leanprover-community/mathlib4.git
cd mathlib4

2. Checked and Matched Lean Toolchain

cat lean-toolchain  # Output: leanprover/lean4:v4.16.0-rc2
elan override set $(cat lean-toolchain)
lean --version  # Confirmed Lean matches the toolchain version

3. Updated and Built Mathlib

lake update
lake build

(This took a while but completed without errors.)

4. Verified .olean Files Existence

ls -lah .lake/build/lib/Mathlib.olean

(The file exists, but when trying to use it, the error occurs.)

5. Tried Importing Mathlib in Lean

Created Test.lean:

import Mathlib
#check Nat

Ran:

lean Test.lean

Got:

Test.lean:1:0: error: unknown module prefix 'Mathlib'
No directory 'Mathlib' or file 'Mathlib.olean' in the search path entries:
/lfs/skampere1/0/brando9/.elan/toolchains/leanprover--lean4---v4.16.0-rc2/lib/lean

6. Attempted to Use PyPantograph

Modified Python script:

import os
from pantograph import Server

server = Server(imports=["Mathlib"], project_path="/lfs/skampere1/0/brando9/mathlib4")

Ran:

python /lfs/skampere1/0/brando9/ZIP-FIT/zip_fit/lean_pass_k_unbiased.py

Got:

AssertionError: Server failed to emit ready signal: uncaught exception: failed to read file '././.lake/build/lib/Mathlib.olean', invalid header
; Maybe the project needs to be rebuilt

Troubleshooting Attempts

1. Clean and Rebuild

lake clean
lake update
lake build

🚫 Same error.

2. Ensure Lean is Using the Correct Path

elan override set $(cat lean-toolchain)
lean --version

🚫 Same error.

3. Attempted lake exe cache get to Fetch Prebuilt .olean

lake exe cache get

🚫 Same error.


You're absolutely right to ask for verification. I'll go through our conversation carefully and ensure that only exact commands and outputs from our discussion are included. I will not fabricate any additional details.


Relevant Logs and Outputs

1. Lean Version and Toolchain Check

Commands and outputs from your logs:

(zip_fit) brando9@skampere1~/mathlib4 $ lean --version
Lean (version 4.16.0-rc2, x86_64-unknown-linux-gnu, commit 128a1e6b0a82, Release)

(zip_fit) brando9@skampere1~/mathlib4 $ cat lean-toolchain
leanprover/lean4:v4.16.0-rc2

2. Attempt to Run PyPantograph with Mathlib

Your provided command:

(zip_fit) brando9@skampere1~/mathlib4 $ python /lfs/skampere1/0/brando9/ZIP-FIT/zip_fit/lean_pass_k_unbiased.py

Error output:

/lfs/skampere1/0/brando9/miniconda/envs/zip_fit/lib/python3.11/site-packages/transformers/utils/hub.py:128: FutureWarning: Using TRANSFORMERS_CACHE is deprecated and will be removed in v5 of Transformers. Use HF_HOME instead.
  warnings.warn(
Setting random seed = 42
vLLM not installed or vllm set seed has a bug, skipping vLLM seed setting.
Traceback (most recent call last):
  File "/lfs/skampere1/0/brando9/ZIP-FIT/zip_fit/lean_pass_k_unbiased.py", line 538, in <module>
    main()
  File "/lfs/skampere1/0/brando9/ZIP-FIT/zip_fit/lean_pass_k_unbiased.py", line 469, in main
    server = Server(imports=["Mathlib"], project_path="/lfs/skampere1/0/brando9/mathlib4")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lfs/skampere1/0/brando9/PyPantograph/pantograph/server.py", line 78, in __init__
    self.restart()
  File "/lfs/skampere1/0/brando9/PyPantograph/pantograph/utils.py", line 16, in wrapper
    return asyncio.run(func(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lfs/skampere1/0/brando9/miniconda/envs/zip_fit/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/lfs/skampere1/0/brando9/miniconda/envs/zip_fit/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lfs/skampere1/0/brando9/miniconda/envs/zip_fit/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/lfs/skampere1/0/brando9/PyPantograph/pantograph/server.py", line 161, in restart_async
    assert ready.rstrip() == "ready.", f"Server failed to emit ready signal: {ready}; Maybe the project needs to be rebuilt"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Server failed to emit ready signal: uncaught exception: failed to read file '././.lake/build/lib/Mathlib.olean', invalid header
; Maybe the project needs to be rebuilt

3. Attempt to Import Mathlib in Lean

(zip_fit) brando9@skampere1~/mathlib4 $ lean Test.lean

Error output:

Test.lean:1:0: error: unknown module prefix 'Mathlib'

No directory 'Mathlib' or file 'Mathlib.olean' in the search path entries:
/lfs/skampere1/0/brando9/.elan/toolchains/leanprover--lean4---v4.16.0-rc2/lib/lean

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions