Skip to content

Commit 1e7994f

Browse files
damonbayerasottile
authored andcommitted
set JULIA_DEPOT_PATH
1 parent ff8541f commit 1e7994f

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

pre_commit/languages/julia.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ def get_env_patch(target_dir: str, version: str) -> PatchesT:
5151
('JULIA_LOAD_PATH', target_dir),
5252
# May be set, remove it to not interfer with LOAD_PATH
5353
('JULIA_PROJECT', UNSET),
54+
# Keep the package depot inside the hook environment so installed
55+
# packages and precompile caches persist with the env instead of
56+
# leaking into a shared depot. The trailing separator leaves an empty
57+
# entry, which julia expands to its default depots. This keeps the
58+
# bundled stdlib resources (and their precompile caches) available so
59+
# hooks don't recompile from scratch on first run.
60+
('JULIA_DEPOT_PATH', os.path.join(target_dir, 'depot') + os.pathsep),
5461
)
5562

5663

tests/languages/julia_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import os
44
from unittest import mock
55

6+
from pre_commit import constants as C
67
from pre_commit.languages import julia
8+
from pre_commit.prefix import Prefix
79
from testing.language_helpers import run_language
810
from testing.util import cwd
911

@@ -42,6 +44,19 @@ def test_julia_hook_with_startup(tmp_path):
4244
test_julia_hook(tmp_path)
4345

4446

47+
def test_julia_hook_installs_into_env_local_depot(tmp_path):
48+
code = """
49+
using Example
50+
println("Hello, world!")
51+
"""
52+
_make_hook(tmp_path, code)
53+
54+
julia.install_environment(Prefix(str(tmp_path)), C.DEFAULT, ())
55+
56+
d = tmp_path.joinpath('juliaenv-default', 'depot', 'packages', 'Example')
57+
assert d.is_dir()
58+
59+
4560
def test_julia_hook_manifest(tmp_path):
4661
code = """
4762
using Example

0 commit comments

Comments
 (0)