Skip to content

Commit

Permalink
fix: LD_LIBRARY_PATH and DYLD_LIBRARY_PATH should be unset in subproject
Browse files Browse the repository at this point in the history
  • Loading branch information
david-christiansen committed Mar 6, 2024
1 parent 46d0607 commit f911350
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion demo/lakefile.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import Lake
open Lake DSL

require subverso from ".."
-- This needs to be git rather than a filesystem path, because git
-- will clone the project. This results in a separate .lake build dir,
-- so the different versions of Lake don't stomp on each others'
-- files.
require subverso from git ".."

package «demo» where
-- add package configuration options here
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:nightly-2024-02-26
leanprover/lean4:4.6.0
13 changes: 12 additions & 1 deletion src/examples/SubVerso/Examples.lean
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ partial def loadExamples (leanProject : FilePath) : IO (NameMap (NameMap Example
if !(← lakefile.pathExists) then
throw <| .userError s!"File {lakefile} doesn't exist, couldn't load project"

-- Kludge: path entries likely added by Elan
let newpath := System.SearchPath.parse ((← IO.getEnv "PATH").getD "") |>.filter ("toolchains" ∉ ·.toString.splitOn "/")

-- Kludge: remove variables introduced by Lake. Clearing out DYLD_LIBRARY_PATH and
-- LD_LIBRARY_PATH is useful so the version selected by Elan doesn't get the wrong shared
-- libraries.
let lakeVars :=
#["LAKE", "LAKE_HOME", "LAKE_PKG_URL_MAP",
"LEAN_SYSROOT", "LEAN_AR", "LEAN_PATH", "LEAN_SRC_PATH",
"ELAN_TOOLCHAIN", "DYLD_LIBRARY_PATH", "LD_LIBRARY_PATH"]

let lake ← findElanLake

-- Build the facet
Expand All @@ -125,7 +136,7 @@ partial def loadExamples (leanProject : FilePath) : IO (NameMap (NameMap Example
args := #["build", ":examples"]
cwd := projectDir
-- Unset Lake's environment variables
env := #["LAKE", "LAKE_HOME", "LAKE_PKG_URL_MAP", "LEAN_SYSROOT", "LEAN_AR", "LEAN_PATH", "LEAN_SRC_PATH", "ELAN_TOOLCHAIN"].map (·, none)
env := lakeVars.map (·, none)
}
if res.exitCode != 0 then
IO.eprintln <|
Expand Down

0 comments on commit f911350

Please sign in to comment.