leanprover / leanprover/lean4

lake: improve functionality in read-only container

Open
#7,814 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Lake P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

Lake does not work in read-only file system when the absolute path has changed, even if it should not need to do anything (for example when lake build --no-build is supposed to succeed).

Context

This would allow the web editor at live.lean-lang.org to use the leanOptions defined in the lakefile.

The web editor wants to build the project completely outside any container and then run lake serve -- inside a read-only container for any user accessing it.

Steps to Reproduce
  1. Ensure you have bubblewrap installed
  2. create any lake project with at least one dependency. For simplicity that could be lake new Bubblewrap math but does not need to be mathlib.
  3. cd Bubblewrap
  4. Create the sample bubblewrap-script to simulate read-only environment:
    touch bubblewrap.sh
    chmod a+x bubblewrap.sh
    nano bubblewrap.sh
    
    and fill it with the following content
    #!/bin/bash
    LEAN_ROOT="$(lean --print-prefix)"
    LEAN_PATH="$(lake env printenv LEAN_PATH)"
    (exec bwrap\
      --ro-bind "." "/project" \
      --ro-bind "$LEAN_ROOT" /lean \
      --ro-bind /usr /usr \
      --dev /dev \
      --tmpfs /tmp \
      --proc /proc \
      --symlink usr/lib /lib\
      --symlink usr/lib64 /lib64\
      --symlink usr/bin /bin\
      --symlink usr/sbin /sbin\
      --clearenv \
      --setenv PATH "/lean/bin" \
      --setenv LAKE "/no" `# tries to invoke git otherwise` \
      --setenv LEAN_PATH "$LEAN_PATH" \
      --unshare-user \
      --unshare-pid  \
      --unshare-net  \
      --unshare-uts  \
      --unshare-cgroup \
      --die-with-parent \
      --chdir "/project/" \
      lake build --no-build
    )
    
  5. Build the project normally: lake build
  6. Ensure it's built if you want: lake build --no-build
  7. Try ./bubblewrap.sh and observe the error message

Expected behavior: I'd expect now that ./bubblewrap.sh would succeed because everything has been built already and there is nothing to change.

Actual behavior: However, lake throws an error about updating the URL of the dependency:

info: mathlib: URL has changed; deleting '././.lake/packages/mathlib' and cloning again
error: read-only file system (error code: 30)
  file: ././.lake/packages/mathlib/Counterexamples.lean

This is confusing because I don't think lake should need to update any revs or URLs of packages at this stage.

Versions

leanprover/lean4:v4.19.0-rc2
Linux (Ubuntu)

Additional Information

bubblewrap can usually be installed with sudo apt-get install bubblewrap

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided bubblewrap.sh reproduction and compare lake build with and without --no-build after the project is built normally. Trace Lake's dependency URL update path for the read-only invocation, using the reported mathlib package error as the failure point. Done means lake build --no-build succeeds in the read-only container without attempting to modify the dependency checkout.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, shell
Domain
build-system, cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.