From 4da611aa2066aedc33766c0199b8e80b79ae5c6d Mon Sep 17 00:00:00 2001 From: lijinhong11 <62691956+lijinhong11@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:12:26 +0800 Subject: [PATCH 1/2] Update InternalResourceRoots.java --- .../com/oracle/truffle/polyglot/InternalResourceRoots.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java index f21819dece4d..3dcd0cc9f839 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java @@ -319,8 +319,10 @@ private static ResolvedCacheFolder findCacheRootDefault() { case LINUX -> { ResolvedCacheFolder userCacheDir = null; String xdgCacheValue = System.getenv("XDG_CACHE_HOME"); - if (xdgCacheValue != null) { - try { + if (xdgCacheValue == null) { + xdgCacheValue = System.getProperty("XDG_CACHE_HOME"); + } + try { Path xdgCacheDir = Path.of(xdgCacheValue); // Do not fail when XDG_CACHE_HOME value is invalid. Fall back to // $HOME/.cache. From a290468c2cb8c54b9885daa279fc5f6fe71185aa Mon Sep 17 00:00:00 2001 From: lijinhong11 <62691956+lijinhong11@users.noreply.github.com> Date: Sun, 20 Jul 2025 11:52:07 +0800 Subject: [PATCH 2/2] Update InternalResourceRoots.java --- .../polyglot/InternalResourceRoots.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java index 3dcd0cc9f839..c65e6462e452 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java @@ -320,20 +320,19 @@ private static ResolvedCacheFolder findCacheRootDefault() { ResolvedCacheFolder userCacheDir = null; String xdgCacheValue = System.getenv("XDG_CACHE_HOME"); if (xdgCacheValue == null) { - xdgCacheValue = System.getProperty("XDG_CACHE_HOME"); + xdgCacheValue = System.getProperty("xdg.cache.home"); } try { - Path xdgCacheDir = Path.of(xdgCacheValue); - // Do not fail when XDG_CACHE_HOME value is invalid. Fall back to - // $HOME/.cache. - if (xdgCacheDir.isAbsolute()) { - userCacheDir = new ResolvedCacheFolder(xdgCacheDir, "XDG_CACHE_HOME env variable", xdgCacheDir); - } else { - emitWarning("The value of the environment variable 'XDG_CACHE_HOME' is not an absolute path. Using the default cache folder '%s'.", userHome.resolve(".cache")); - } - } catch (InvalidPathException notPath) { - emitWarning("The value of the environment variable 'XDG_CACHE_HOME' is not a valid path. Using the default cache folder '%s'.", userHome.resolve(".cache")); + Path xdgCacheDir = Path.of(xdgCacheValue); + // Do not fail when XDG_CACHE_HOME value is invalid. Fall back to + // $HOME/.cache. + if (xdgCacheDir.isAbsolute()) { + userCacheDir = new ResolvedCacheFolder(xdgCacheDir, "XDG_CACHE_HOME env/property variable", xdgCacheDir); + } else { + emitWarning("The value of the environment/property variable 'XDG_CACHE_HOME' is not an absolute path. Using the default cache folder '%s'.", userHome.resolve(".cache")); } + } catch (InvalidPathException notPath) { + emitWarning("The value of the environment/property variable 'XDG_CACHE_HOME' is not a valid path. Using the default cache folder '%s'.", userHome.resolve(".cache")); } if (userCacheDir == null) { userCacheDir = new ResolvedCacheFolder(userHome.resolve(".cache"), "user home", userHome);