Pass COURSIER_CACHE to coursier when fetching unpinned repositories#1601
Pass COURSIER_CACHE to coursier when fetching unpinned repositories#1601vadikmironov wants to merge 1 commit into
Conversation
Coursier derives its default cache location from the JVM's `user.home`, which on Linux comes from the passwd database and ignores $HOME, while these rules derive the shared cache location from $HOME. When the two disagree (e.g. $HOME remapped to a network mount), repinning bypasses the shared cache and fails with "Error while trying to parse the path of file in the coursier cache". Pass the computed location to the spawned coursier process via COURSIER_CACHE, as the pinned flow already does. If no variable a cache location can be derived from is set, leave the environment untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Why not just set the If that's not the right answer, why not make this branch unconditional? |
|
Thanks a lot for the feedback! Setting Making that branch unconditional would pass the repo-local directory for unpinned repos too (defeating the shared cache they are supposed to use). If you meant something like |
|
@shs96c , please do let me know if the explanation make sense? Just to re-iterate - this PR is using |
Coursier derives its default cache location from the JVM's
user.home, which on Linux comes from the passwd database and ignores$HOME, while these rules derive the shared cache location from$HOME(or$XDG_CACHE_HOME). When the two disagree — e.g.$HOMEremapped to a network-mounted home directory — coursier bypasses the shared cache during a repin, re-downloads artifacts into the passwd home, and the fetch then fails with:Repro: on Linux, run
REPIN=1 bazel run @unpinned_maven//:pinwithHOMEpointing anywhere other than the passwd home dir (env HOME=/some/other/dir ... bazel run @unpinned_maven//:pin). Before this change the repin hard-fails as above; after it, coursier uses (and populates) the$HOME-derived shared cache.Fix: always pass the Starlark-computed cache location to the spawned coursier process via the
COURSIER_CACHEenvironment variable, as the pinned flow already does. The logic is extracted intoget_coursier_environment(public for testing). If none of the variables a shared cache location can be derived from is set (HOME/XDG_CACHE_HOME/COURSIER_CACHE), the environment is left untouched so coursier keeps using its own default.Behavior note: a
-Dcoursier.cache=...passed viaCOURSIER_OPTSis now overridden by the forced environment variable in the unpinned flow; that configuration previously failed the relativization step anyway.A follow-up PR will fix the same
user.homevs$HOMEskew in the Java resolver tooling (.netrclookup, local.m2/.gradlecaches).🤖 Generated with Claude Code