Skip to content

Commit 4b2c170

Browse files
Respect XDG_CACHE_HOME in JLineNativeLoader (#5016)
Comes from #4917, but shouldn't be a problem
1 parent ce44e5b commit 4b2c170

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

runner/client/src/mill/runner/client/JLineNativeLoader.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ final class JLineNativeLoader {
3939
System.getProperty("os.name").toLowerCase(Locale.ROOT).startsWith("windows");
4040
final Path baseDir;
4141
if (isWindows) baseDir = Paths.get(System.getenv("UserProfile")).resolve(".mill/cache/");
42-
else baseDir = Paths.get(System.getProperty("user.home")).resolve(".cache/mill/");
42+
else {
43+
final String xdgCacheHome = System.getenv("XDG_CACHE_HOME");
44+
final Path cacheBase;
45+
if (xdgCacheHome == null)
46+
cacheBase = Paths.get(System.getProperty("user.home")).resolve(".cache");
47+
else cacheBase = Paths.get(xdgCacheHome);
48+
baseDir = cacheBase.resolve("mill");
49+
}
4350
this.millJLineNativeDir = baseDir.resolve("jline/" + jlineNativeVersion);
4451
this.millJLineNativeLibLocation =
4552
millJLineNativeDir.resolve(OSInfo.getNativeLibFolderPathForCurrentOS() + "/"

0 commit comments

Comments
 (0)