Skip to content

feat: Set JULIAUP_DEPOT_PATH to a location in the runner tool cache#205

Open
krynju wants to merge 5 commits into
julia-actions:mainfrom
krynju:kr/depot-runner-cache
Open

feat: Set JULIAUP_DEPOT_PATH to a location in the runner tool cache#205
krynju wants to merge 5 commits into
julia-actions:mainfrom
krynju:kr/depot-runner-cache

Conversation

@krynju
Copy link
Copy Markdown

@krynju krynju commented Apr 30, 2026

Found because a worker had juliaup preinstalled and we've hit Error: The Julia launcher failed to figure out which juliaup channel to use.

I think it makes more sense to put it in the runner cache, so that it completely ignores what's currently on the runner.

@krynju krynju force-pushed the kr/depot-runner-cache branch from 5c5902d to 0b83653 Compare April 30, 2026 15:57
@DilumAluthge DilumAluthge self-requested a review April 30, 2026 23:56
@DilumAluthge
Copy link
Copy Markdown
Member

Would you be able to put the changes that touch lib/* and dist/* into a separate commit? It makes review a little easier, and also it makes it easier when rebasing and fixing merge conflicts.

@DilumAluthge
Copy link
Copy Markdown
Member

At first glance, at a high-level, this seems reasonable to me, but I haven't done a line-by-line review yet.

@krynju krynju force-pushed the kr/depot-runner-cache branch from 0b83653 to 0f17925 Compare May 5, 2026 16:16
@krynju
Copy link
Copy Markdown
Author

krynju commented May 5, 2026

Would you be able to put the changes that touch lib/* and dist/* into a separate commit? It makes review a little easier, and also it makes it easier when rebasing and fixing merge conflicts.

Done

Comment thread src/start_here.ts Outdated
core.info(`${env_name} already set to: ${existing}`)
return
}
const tool_cache = process.env['RUNNER_TOOL_CACHE']
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.

Is there an API in any of the @actions/ packages for getting this value? It's not the end of the world to read it from the environment, but an API might be better.

E.g. does @actions/tool-cache have any public API that we can use?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

_getCacheDirectory is private in @actions/tool-cache and it does the same thing as we do here (just getting it from the env directly)

https://github.com/actions/toolkit/blob/cf80afb3922317b98dd74d27cba7cf1032c1fe50/packages/tool-cache/src/tool-cache.ts#L745-L749

It doesn't look like there are any non hacky public entrypoints for this
Searched github and it seems other actions are also using the ENV directly

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.

Hmmm. What about doing something like this?

let juliaup_depot_path: string

juliaup_depot_path = tc.find("juliaup_depot_path", "all_versions", "all_arches")

if (!juliaup_depot_path) {
    const my_empty_tempdir = [code to create a new empty temp directory]
    juliaup_depot_path = await tc.cacheDir(my_empty_tempdir, tool_name, "all_versions", "all_arches")
}

That way, we're only relying on public API, and we don't need the environment variable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added this in 16d5746
Seems to work. Can't use all_versions though, needs to be semver, so I set it to 3.0.0 (same major as install-juliaup)

It doesn't follow the pattern a bit, because the tools are apparently meant to be immutable once set, but I guess it doesn't matter too much.

I found that the runner tool cache env is public too, so either solution for me is ok. https://docs.github.com/en/actions/reference/workflows-and-actions/variables#:~:text=D%3A%5Ca%5C_temp-,RUNNER_TOOL_CACHE,-The%20path%20to

Copy link
Copy Markdown
Member

@DilumAluthge DilumAluthge May 13, 2026

Choose a reason for hiding this comment

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

because the tools are apparently meant to be immutable once set

Interesting. Does that suggest that we shouldn't be using the toolcache at all?

Is there prior art here? What do other tools do on GitHub Actions? E.g. Node/Rust/Python/UV?

@MichaelHatherly What do you think about this? Some options are:

  1. Read the RUNNER_TOOL_CACHE environment variable, and use that.
    • Pros:
      • It's public API (per the link Krystian posted above).
      • Prevents clashing with ~/.julia/juliaup
    • Cons:
      • Does GitHub intend for the entire toolcache to be immutable once written?
  2. Use the tc.cacheDir function.
    • Pros:
      • tc.cacheDir is public API.
      • Prevents clashing with ~/.julia/juliaup
    • Cons:
      • We have to specify a semver version number (we can't use something like ALL_VERSIONS).
      • Does GitHub intend for this kind of toolcache entry to be immutable once written?
  3. Something else?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The common usage pattern seems to be mostly around immutable binaries, but I haven't found any requirement for that in source code or elsewhere, so I think we're good to go here

For me either toolcache usage or just putting it directly in runner tool cache seem like the same deal and both are ok. Toolcache has more logic built in, but we're skipping all of that in this pattern.

As for direct storage in RUNNER_TOOL_CACHE two major actions are doing it: setup-java and setup-python

I also looked for other actions similiar to juliaup in functionality and found this example of a mutable depot in the cache:

volta-cli/action

  // installer.ts:220-241
  let voltaHome = tc.find('volta', version);
  if (voltaHome === '') {
      const toolRoot = await acquireVolta(version, options);
      voltaHome = await tc.cacheDir(toolRoot, 'volta', version);
      await setupVolta(version, voltaHome);  // runs `volta setup` — populates dir
  }
  core.addPath(path.join(voltaHome, 'bin'));
  core.exportVariable('VOLTA_HOME', voltaHome);  // ← depot env var = tool-cache path

What Volta does:

  1. Caches Volta binary at $RUNNER_TOOL_CACHE/volta/// via tc.cacheDir (normal usage).
  2. Sets VOLTA_HOME to that same tool-cache path.
  3. Volta then installs Node versions into $VOLTA_HOME/bin/, $VOLTA_HOME/tools/, etc. — the tool-cache directory is the depot.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have no strong preference for any of those options. Just following along with what the java and python ones are doing seems reasonable in my mind.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@DilumAluthge want me to revert the latest toolcache commit or are we leaving it as is?

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.

Ah, thanks for the bump. Let me follow up later today.

@DilumAluthge
Copy link
Copy Markdown
Member

I left one comment, but overall this makes sense and we should do it.

Users can recover the old behavior by manually setting the JULIAUP_DEPOT_PATH environment variable themselves.

One question though, is whether this is breaking. My initial instinct is that it is breaking. @MichaelHatherly what do you think?

We could work around it by making it opt-in in the current major version of install-juliaup, which would be nonbreaking. And then we could change the default in a future major release.

@MichaelHatherly
Copy link
Copy Markdown
Collaborator

My initial instinct is that it is breaking.

I'm inclined to agree with that. Opt-in during this current major release and then switching it in the next might be the most reasonable.

@krynju
Copy link
Copy Markdown
Author

krynju commented May 7, 2026

My initial instinct is that it is breaking.

I'm inclined to agree with that. Opt-in during this current major release and then switching it in the next might be the most reasonable.

Assuming people use the action as intended it shouldn't be breaking. The only side effect I think would be that the cache is not reused on next the first run after the upgrade.
But I'm not 100% sure people use it as intended

@DilumAluthge DilumAluthge changed the title feat: set juliaup depot env to a location in the runner tool cache feat: Set JULIAUP_DEPOT_PATH to a location in the runner tool cache May 11, 2026
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.

3 participants