Skip to content

Proper JULIA_DEPOT_PATH#335

Open
damonbayer wants to merge 2 commits into
pre-commit-ci:mainfrom
damonbayer:dmb_julia_depot
Open

Proper JULIA_DEPOT_PATH#335
damonbayer wants to merge 2 commits into
pre-commit-ci:mainfrom
damonbayer:dmb_julia_depot

Conversation

@damonbayer

@damonbayer damonbayer commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This should fix the speed issues mentioned in #332 (comment).

The explanation is in the julia docs:

This allows easy overriding of the user depot, while still retaining access to resources that are bundled with Julia, like cache files, artifacts, etc. For example, to switch the user depot to /foo/bar use a trailing :

export JULIA_DEPOT_PATH="/foo/bar:"

All package operations, like cloning registries or installing packages, will now write to /foo/bar, but since the empty entry is expanded to the default system depot, any bundled resources will still be available. If you really only want to use the depot at /foo/bar, and not load any bundled resources, simply set the environment variable to /foo/bar without the trailing colon.

We had inadvertently been "not load[ing] any bundled resources", requiring us to instantiate Pkg at hook install time, which took > 1.5 min. Now it is already instantiated and can be used instantaneously.

Tagging @asottile for review.

@damonbayer damonbayer changed the title idiomatic JULIA_DEPOT_PATH Proper JULIA_DEPOT_PATH Jun 8, 2026
Comment thread Dockerfile Outdated
ENV \
PATH=/opt/julia/bin:$PATH \
JULIA_DEPOT_PATH=/pc/julia_depot
JULIA_DEPOT_PATH=/pc/julia_depot:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I missed this in the first review but nothing should use /pc for writable space -- it's intended to be only for the hook installs themselves (and everything else there is ephemeral / blown away)

@damonbayer damonbayer Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile Okay, I think this actually points to an upstream problem with pre-commit itself, which is that the packages used by julia hooks get installed into the global depot, not a hook-specific environment.

As I understand it, the default JULIA_DEPOT_PATH (~/.julia) does not persist across the hook installation and the run phase in pre-commit.ci. This is why I could not leave JULIA_DEPOT_PATH unset in my initial PR.

As a workaround, I set the JULIA_DEPOT_PATH inside of /pc which does persist. As you say, this is not quite what the /pc directory is for.

I think the right fix is to set JULIA_DEPOT_PATH in get_env_patch to a depot inside the hook env dir that's already used for JULIA_LOAD_PATH, e.g. os.path.join(target_dir, 'depot') + os.pathsep. The trailing separator maintains the speedup I intended to implement in this PR.

Does that sound right to you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that sounds right to me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile I opened pre-commit/pre-commit#3711 and committed 117f36e (this PR) in anticipation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants