Page MenuHomePhorge

Arcanist writes cache files to its source directory, and this prevents packaging
Closed, ResolvedPublic

Asked by fgaz on Oct 3 2023, 14:13.


As written in the title, arcanist mixes user data with its own code, with no way to tell it to put it somewhere else. Specifically, it tries to write libexec/arcanist/src/.phutil_module_cache.

This can be a problem when packaging arc, because the install location is read-only.

Locally, I solved the issue with this patch (apache 2.0 licensed):

diff --git a/src/moduleutils/PhutilLibraryMapBuilder.php b/src/moduleutils/PhutilLibraryMapBuilder.php
index f51fc464..b80a22cd 100644
--- a/src/moduleutils/PhutilLibraryMapBuilder.php
+++ b/src/moduleutils/PhutilLibraryMapBuilder.php
@@ -121,7 +121,10 @@ final class PhutilLibraryMapBuilder extends Phobject {
    * @task path
   private function getPathForSymbolCache() {
-    return $this->getPath('.phutil_module_cache');
+    $cachedir = getenv('XDG_CACHE_HOME');
+    if(!$cachedir)
+      $cachedir = getenv('HOME') . '/.cache';
+    return $cachedir . '/arcanist/phutil_module_cache';
@@ -206,6 +209,10 @@ final class PhutilLibraryMapBuilder extends Phobject {
     $json = json_encode($cache);
+    if (!file_exists(dirname($cache_file)))
+      mkdir(dirname($cache_file), 0755, true);
     Filesystem::writeFile($cache_file, $json);

It works well for me, but cache directories are platform-dependent (example) so the patch is not complete.

Could (a complete version of) this be integrated in the project?

Answer Summary

With D25446, Q77#A106 can be applied


Updated 231 Days Ago

Interesting. Thanks!

Could libexec/arcanist/src/.phutil_module_cache just be a symlink to somewhere else?

Updated 222 Days Ago

The location .phutil_module_cache cannot be redirected to $cachedir, because it's always found in the root of each libphutil library - arc is one such library, phorge is another.

But it's only a function of the code itself, so if you're packaging arc as an artifact, you can add the .phutil_module_cache file into the packaged artifact.

You can create the file by running ./support/lib/rebuild-map.php src/ - it takes a few seconds.

See this patch:

D25446: only update cache file if something changed

New Answer


This question has been marked as closed, but you can still leave a new answer.