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..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 @@ -319,19 +319,20 @@ private static ResolvedCacheFolder findCacheRootDefault() { case LINUX -> { ResolvedCacheFolder userCacheDir = null; String xdgCacheValue = System.getenv("XDG_CACHE_HOME"); - if (xdgCacheValue != null) { - 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")); + 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. + 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);