Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pre_commit/languages/julia.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def get_env_patch(target_dir: str, version: str) -> PatchesT:
('JULIA_LOAD_PATH', target_dir),
# May be set, remove it to not interfer with LOAD_PATH
('JULIA_PROJECT', UNSET),
# Keep the package depot inside the hook environment so installed
# packages and precompile caches persist with the env instead of
# leaking into a shared depot. The trailing separator leaves an empty
# entry, which julia expands to its default depots. This keeps the
# bundled stdlib resources (and their precompile caches) available so
# hooks don't recompile from scratch on first run.
('JULIA_DEPOT_PATH', os.path.join(target_dir, 'depot') + os.pathsep),
)


Expand Down
15 changes: 15 additions & 0 deletions tests/languages/julia_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import os
from unittest import mock

from pre_commit import constants as C
from pre_commit.languages import julia
from pre_commit.prefix import Prefix
from testing.language_helpers import run_language
from testing.util import cwd

Expand Down Expand Up @@ -42,6 +44,19 @@ def test_julia_hook_with_startup(tmp_path):
test_julia_hook(tmp_path)


def test_julia_hook_installs_into_env_local_depot(tmp_path):
code = """
using Example
println("Hello, world!")
"""
_make_hook(tmp_path, code)

julia.install_environment(Prefix(str(tmp_path)), C.DEFAULT, ())

d = tmp_path.joinpath('juliaenv-default', 'depot', 'packages', 'Example')
assert d.is_dir()


def test_julia_hook_manifest(tmp_path):
code = """
using Example
Expand Down
Loading