Skip to content

julia: keep the package depot inside the hook env - #113

Merged
blairham merged 1 commit into
mainfrom
julia-depot-104
Oct 15, 2026
Merged

blairham merged 1 commit into
mainfrom
julia-depot-104

Conversation

@blairham

Copy link
Copy Markdown
Owner

Closes #104

Upstream 4.6.1 (pre-commit/pre-commit#3711) added JULIA_DEPOT_PATH=<envdir>/depot + os.pathsep to julia's get_env_patch. Without it, every julia hook installs packages and precompile caches into the user's shared ~/.julia. The trailing separator leaves an empty entry, which julia expands to its default depots, so the bundled stdlib caches stay usable.

  • juliaEnv(envDir) builds the override. Julia's InstallEnvironment and Run both pass it to the child.
  • RunCommand couldn't take env, so a new RunCommandEnv does; RunCommand delegates to it unchanged.
  • Tests: one pins the exact string. The other puts a fake julia on PATH, with a conflicting JULIA_DEPOT_PATH already in the environment, and checks that install and run both hand the hook's depot to the child (skipped on Windows). Both fail if the env isn't passed to install and run, and both fail if the trailing separator is dropped.

Further divergence from upstream julia.py (not fixed here)

  • JULIA_LOAD_PATH / JULIA_PROJECT: upstream sets JULIA_LOAD_PATH=<envdir> and unsets JULIA_PROJECT. We set neither; we pass --project=<envDir> instead.
  • Env dir name: upstream's is juliaenv; ours is julia_env. That breaks cache-layout compatibility.
  • Run looks like it drops the script: it runs julia --startup-file=no --project=<env> parts[1:]..., which drops parts[0] (the hook's .jl file). Upstream runs julia --startup-file=no <prefix>/<script> ... (left unprefixed for local hooks) through xargs. This comes from reading the code; I haven't run it against a real julia.
  • Install: upstream copies (Julia)Project.toml and (Julia)Manifest.toml into the env, or creates an empty Project.toml, then runs Pkg.instantiate with @stdlib added temporarily and adds extra deps via pkg"add ...". Ours runs Pkg.activate / Pkg.develop(path=prefix) / Pkg.add per dep, with paths spliced into Julia source unescaped.

These are probably worth a follow-up issue.

Upstream 4.6.1 (pre-commit/pre-commit#3711) sets JULIA_DEPOT_PATH to
<envdir>/depot plus a trailing path separator in julia's env patch. Without
it, every julia hook installs packages and precompile caches into the
user's shared ~/.julia, so hook envs are not self-contained and
`pre-commit clean` leaves them behind. The trailing separator keeps
julia's default depots after ours, so the bundled stdlib caches stay
usable and hooks don't recompile from scratch.

RunCommand had no way to pass env, so Run goes through a new
RunCommandEnv; RunCommand delegates to it unchanged.
@blairham
blairham merged commit 5d70c9f into main Oct 15, 2026
13 checks passed
@blairham
blairham deleted the julia-depot-104 branch October 15, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

language: julia: set JULIA_DEPOT_PATH (upstream 4.6.1)

1 participant