Troubleshooting¶
This guide covers common issues you might encounter when using LeanInteract.
Common Issues¶
Out of Memory Errors¶
Symptoms:
- The application crashes with memory-related errors
- Python process is killed by the operating system
- Error messages mentioning "MemoryError" or "Killed"
Solutions:
- Reduce parallel processing or increase system memory
- Use
AutoLeanServer
with conservative memory settings:
from lean_interact import AutoLeanServer
server = AutoLeanServer(config, memory_threshold_mb=1000) # Limit to 1GB
- Avoid working with large files or complex proofs in a single session
- Use environment pickling to save and restore states across sessions
Timeout Errors¶
Symptoms:
- Commands take too long to execute
- Error messages mentioning "TimeoutError"
Solutions:
- Increase the timeout in the configuration:
- Use
AutoLeanServer
for automatic recovery from timeouts:
- Break complex commands into smaller, more manageable pieces
Long Waiting Times During First Run¶
Symptoms:
- Initial setup takes a long time
- Process seems stuck at "Downloading" or "Building"
Solution: This is expected behavior as LeanInteract:
- Downloads and sets up the specified Lean version
- Downloads and builds Lean REPL
- If using Mathlib, downloads it and instantiates a project using it (which is resource-intensive)
Subsequent runs will be much faster due to caching.
Lake Update Errors¶
Symptoms:
- Error:
Failed during Lean project setup: Command '['lake', 'update']' returned non-zero exit status 1.
Solutions:
- Update your
elan
version (should be at least 4.0.0):
- Check your project's lake file for errors
- Ensure Git is properly installed and can access required repositories
Path Too Long Error (Windows)¶
Symptoms:
- On Windows, errors related to path length limitations
- Git errors about paths exceeding 260 characters
Solutions: Enable long paths in Windows 10/11:
# Run in administrator PowerShell
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -Value 1 -PropertyType DWord -Force
git config --system core.longpaths true
Cache Issues¶
Symptoms:
- Unexpected behavior after upgrading LeanInteract
- Errors about incompatible versions
Solution: Clear the LeanInteract cache:
Unexpected Lean error messages¶
Symptom: LeanInteract returns error messages while the Lean code runs fine in VSCode.
Solutions:
- Check you are using the same Lean version in both environments
- If you are creating a temporary project using LeanInteract, make sure your dependencies are correctly set and compatible with the Lean version you are using
-
A frequent issue is forgetting to include
mathlib
in the dependencies: -
Check if a similar issue for the Lean REPL has been reported
"'elan' is not recognized as an internal or external command"¶
Symptom: Error when running LeanInteract on a new system
Solution: Install Lean's version manager:
Getting Additional Help¶
If you encounter issues not covered in this guide:
- Check the GitHub repository for open issues
- Open a new issue with:
- A minimal reproducible example
- Your operating system and Python version
- LeanInteract version (
pip show lean-interact
) - Complete error message/stack trace