We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
CompilerGym cache directory defaults don't doesn't play nicely with shared access machines
## 🐛 Bug

The default locations of the CompilerGym caches are in shared folders. On multi-user machines this can cause permission errors as the directory may be created by one user without write permissions to other users. I propose switching to user-specific defaults like so:

- [x] `COMPILER_GYM_CACHE` -> `/tmp/compiler_gym-$user`
- [x] `COMPILER_YM_TRANSIENT_CACHE` -> `/dev/shm/compiler_gym-$user`


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `compiler_gym/util/runfiles_path.py`
Content:
```
1 # Copyright (c) Facebook, Inc. and its affiliates.
2 #
3 # This source code is licensed under the MIT license found in the
4 # LICENSE file in the root directory of this source tree.
5 """Module for resolving a runfiles path."""
6 import getpass
7 import os
8 from pathlib import Path
9 
10 # NOTE(cummins): Moving this file may require updating this relative path.
11 _PACKAGE_ROOT = Path(os.path.join(os.path.dirname(__file__), "../../")).resolve(
12     strict=True
13 )
14 
15 
16 def runfiles_path(relpath: str) -> Path:
17     """Resolve the path to a runfiles data path.
18 
19     No checks are to made to ensure that the path, or the containing directory,
20     exist.
21 
22     Use environment variable COMPILER_GYM_RUNFILES=/path/to/runfiles if running
23     outside of bazel.
24 
25     :param relpath: The relative path within the runfiles tree.
26 
27     :return: An absolute path.
28     """
29     # There are three ways of determining a runfiles path:
30     #   1. Set the COMPILER_GYM_RUNFILES environment variable.
31     #   2. Using the rules_python library that is provided by bazel. This will
32     #      fail if not being executed within a bazel sandbox.
33     #   3. Computing the path relative to the location of this file. This is the
34     #      fallback approach that is used for when the code has been installed
35     #      by setuptools.
36     runfiles_path = os.environ.get("COMPILER_GYM_RUNFILES")
37     if runfiles_path:
38         return Path(runfiles_path) / relpath
39     else:
40         try:
41             from rules_python.python.runfiles import runfiles
42 
43             return Path(
44                 runfiles.Create().Rlocation(
45                     "CompilerGym" if relpath == "." else f"CompilerGym/{relpath}"
46                 )
47             )
48         except (ModuleNotFoundError, TypeError):
49             return _PACKAGE_ROOT / relpath
50 
51 
52 def site_data_path(relpath: str) -> Path:
53     """Return a path within the site data directory.
54 
55     CompilerGym uses a directory to store persistent site data files in, such as benchmark datasets.
56     The default location is :code:`~/.local/share/compiler_gym`. Set the environment variable
57     :code:`$COMPILER_GYM_SITE_DATA` to override this default location.
58 
59     No checks are to made to ensure that the path, or the containing directory,
60     exist.
61 
62     :param relpath: The relative path within the site data tree.
63 
64     :return: An absolute path.
65     """
66     # NOTE(cummins): This function has a matching implementation in the C++
67     # sources, compiler_gym::service::getSiteDataPath(). Any change to behavior
68     # here must be reflected in the C++ version.
69     forced = os.environ.get("COMPILER_GYM_SITE_DATA")
70     if forced:
71         return Path(forced) / relpath
72     elif os.environ.get("HOME"):
73         return Path("~/.local/share/compiler_gym").expanduser() / relpath
74     else:
75         return Path("/tmp/compiler_gym/site_data") / relpath
76 
77 
78 def cache_path(relpath: str) -> Path:
79     """Return a path within the cache directory.
80 
81     CompilerGym uses a directory to cache files in, such as downloaded content.
82     The default location for this cache is :code:`~/.cache/compiler_gym`. Set
83     the environment variable :code:`$COMPILER_GYM_CACHE` to override this
84     default location.
85 
86     No checks are to made to ensure that the path, or the containing directory,
87     exist.
88 
89     :param relpath: The relative path within the cache tree.
90 
91     :return: An absolute path.
92     """
93     forced = os.environ.get("COMPILER_GYM_CACHE")
94     if forced:
95         return Path(forced) / relpath
96     elif os.environ.get("HOME"):
97         return Path("~/.cache/compiler_gym").expanduser() / relpath
98     else:
99         return Path("/tmp/compiler_gym/cache") / relpath
100 
101 
102 def transient_cache_path(relpath: str) -> Path:
103     """Return a path within the transient cache directory.
104 
105     The transient cache is a directory used to store files that do not need to
106     persist beyond the lifetime of the current process. When available, the
107     temporary filesystem :code:`/dev/shm` will be used. Else,
108     :meth:`cache_path() <compiler_gym.cache_path>` is used as a fallback. Set
109     the environment variable :code:`$COMPILER_GYM_TRANSIENT_CACHE` to override
110     the default location.
111 
112     No checks are to made to ensure that the path, or the containing directory,
113     exist.
114 
115     :param relpath: The relative path within the cache tree.
116 
117     :return: An absolute path.
118     """
119     forced = os.environ.get("COMPILER_GYM_TRANSIENT_CACHE")
120     if forced:
121         return Path(forced) / relpath
122     elif Path("/dev/shm").is_dir():
123         return Path(f"/dev/shm/compiler_gym_{getpass.getuser()}") / relpath
124     else:
125         # Fallback to using the regular cache.
126         return cache_path(relpath)
127
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/compiler_gym/util/runfiles_path.py b/compiler_gym/util/runfiles_path.py
--- a/compiler_gym/util/runfiles_path.py
+++ b/compiler_gym/util/runfiles_path.py
@@ -3,8 +3,8 @@
 # This source code is licensed under the MIT license found in the
 # LICENSE file in the root directory of this source tree.
 """Module for resolving a runfiles path."""
-import getpass
 import os
+from getpass import getuser
 from pathlib import Path
 
 # NOTE(cummins): Moving this file may require updating this relative path.
@@ -72,7 +72,7 @@
     elif os.environ.get("HOME"):
         return Path("~/.local/share/compiler_gym").expanduser() / relpath
     else:
-        return Path("/tmp/compiler_gym/site_data") / relpath
+        return Path(f"/tmp/compiler_gym_{getuser()}/site_data") / relpath
 
 
 def cache_path(relpath: str) -> Path:
@@ -96,7 +96,7 @@
     elif os.environ.get("HOME"):
         return Path("~/.cache/compiler_gym").expanduser() / relpath
     else:
-        return Path("/tmp/compiler_gym/cache") / relpath
+        return Path(f"/tmp/compiler_gym_{getuser()}/cache") / relpath
 
 
 def transient_cache_path(relpath: str) -> Path:
@@ -120,7 +120,7 @@
     if forced:
         return Path(forced) / relpath
     elif Path("/dev/shm").is_dir():
-        return Path(f"/dev/shm/compiler_gym_{getpass.getuser()}") / relpath
+        return Path(f"/dev/shm/compiler_gym_{getuser()}") / relpath
     else:
         # Fallback to using the regular cache.
         return cache_path(relpath)

{"golden_diff": "diff --git a/compiler_gym/util/runfiles_path.py b/compiler_gym/util/runfiles_path.py\n--- a/compiler_gym/util/runfiles_path.py\n+++ b/compiler_gym/util/runfiles_path.py\n@@ -3,8 +3,8 @@\n # This source code is licensed under the MIT license found in the\n # LICENSE file in the root directory of this source tree.\n \"\"\"Module for resolving a runfiles path.\"\"\"\n-import getpass\n import os\n+from getpass import getuser\n from pathlib import Path\n \n # NOTE(cummins): Moving this file may require updating this relative path.\n@@ -72,7 +72,7 @@\n     elif os.environ.get(\"HOME\"):\n         return Path(\"~/.local/share/compiler_gym\").expanduser() / relpath\n     else:\n-        return Path(\"/tmp/compiler_gym/site_data\") / relpath\n+        return Path(f\"/tmp/compiler_gym_{getuser()}/site_data\") / relpath\n \n \n def cache_path(relpath: str) -> Path:\n@@ -96,7 +96,7 @@\n     elif os.environ.get(\"HOME\"):\n         return Path(\"~/.cache/compiler_gym\").expanduser() / relpath\n     else:\n-        return Path(\"/tmp/compiler_gym/cache\") / relpath\n+        return Path(f\"/tmp/compiler_gym_{getuser()}/cache\") / relpath\n \n \n def transient_cache_path(relpath: str) -> Path:\n@@ -120,7 +120,7 @@\n     if forced:\n         return Path(forced) / relpath\n     elif Path(\"/dev/shm\").is_dir():\n-        return Path(f\"/dev/shm/compiler_gym_{getpass.getuser()}\") / relpath\n+        return Path(f\"/dev/shm/compiler_gym_{getuser()}\") / relpath\n     else:\n         # Fallback to using the regular cache.\n         return cache_path(relpath)\n", "issue": "CompilerGym cache directory defaults don't doesn't play nicely with shared access machines\n## \ud83d\udc1b Bug\r\n\r\nThe default locations of the CompilerGym caches are in shared folders. On multi-user machines this can cause permission errors as the directory may be created by one user without write permissions to other users. I propose switching to user-specific defaults like so:\r\n\r\n- [x] `COMPILER_GYM_CACHE` -> `/tmp/compiler_gym-$user`\r\n- [x] `COMPILER_YM_TRANSIENT_CACHE` -> `/dev/shm/compiler_gym-$user`\r\n\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\"\"\"Module for resolving a runfiles path.\"\"\"\nimport getpass\nimport os\nfrom pathlib import Path\n\n# NOTE(cummins): Moving this file may require updating this relative path.\n_PACKAGE_ROOT = Path(os.path.join(os.path.dirname(__file__), \"../../\")).resolve(\n    strict=True\n)\n\n\ndef runfiles_path(relpath: str) -> Path:\n    \"\"\"Resolve the path to a runfiles data path.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    Use environment variable COMPILER_GYM_RUNFILES=/path/to/runfiles if running\n    outside of bazel.\n\n    :param relpath: The relative path within the runfiles tree.\n\n    :return: An absolute path.\n    \"\"\"\n    # There are three ways of determining a runfiles path:\n    #   1. Set the COMPILER_GYM_RUNFILES environment variable.\n    #   2. Using the rules_python library that is provided by bazel. This will\n    #      fail if not being executed within a bazel sandbox.\n    #   3. Computing the path relative to the location of this file. This is the\n    #      fallback approach that is used for when the code has been installed\n    #      by setuptools.\n    runfiles_path = os.environ.get(\"COMPILER_GYM_RUNFILES\")\n    if runfiles_path:\n        return Path(runfiles_path) / relpath\n    else:\n        try:\n            from rules_python.python.runfiles import runfiles\n\n            return Path(\n                runfiles.Create().Rlocation(\n                    \"CompilerGym\" if relpath == \".\" else f\"CompilerGym/{relpath}\"\n                )\n            )\n        except (ModuleNotFoundError, TypeError):\n            return _PACKAGE_ROOT / relpath\n\n\ndef site_data_path(relpath: str) -> Path:\n    \"\"\"Return a path within the site data directory.\n\n    CompilerGym uses a directory to store persistent site data files in, such as benchmark datasets.\n    The default location is :code:`~/.local/share/compiler_gym`. Set the environment variable\n    :code:`$COMPILER_GYM_SITE_DATA` to override this default location.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    :param relpath: The relative path within the site data tree.\n\n    :return: An absolute path.\n    \"\"\"\n    # NOTE(cummins): This function has a matching implementation in the C++\n    # sources, compiler_gym::service::getSiteDataPath(). Any change to behavior\n    # here must be reflected in the C++ version.\n    forced = os.environ.get(\"COMPILER_GYM_SITE_DATA\")\n    if forced:\n        return Path(forced) / relpath\n    elif os.environ.get(\"HOME\"):\n        return Path(\"~/.local/share/compiler_gym\").expanduser() / relpath\n    else:\n        return Path(\"/tmp/compiler_gym/site_data\") / relpath\n\n\ndef cache_path(relpath: str) -> Path:\n    \"\"\"Return a path within the cache directory.\n\n    CompilerGym uses a directory to cache files in, such as downloaded content.\n    The default location for this cache is :code:`~/.cache/compiler_gym`. Set\n    the environment variable :code:`$COMPILER_GYM_CACHE` to override this\n    default location.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    :param relpath: The relative path within the cache tree.\n\n    :return: An absolute path.\n    \"\"\"\n    forced = os.environ.get(\"COMPILER_GYM_CACHE\")\n    if forced:\n        return Path(forced) / relpath\n    elif os.environ.get(\"HOME\"):\n        return Path(\"~/.cache/compiler_gym\").expanduser() / relpath\n    else:\n        return Path(\"/tmp/compiler_gym/cache\") / relpath\n\n\ndef transient_cache_path(relpath: str) -> Path:\n    \"\"\"Return a path within the transient cache directory.\n\n    The transient cache is a directory used to store files that do not need to\n    persist beyond the lifetime of the current process. When available, the\n    temporary filesystem :code:`/dev/shm` will be used. Else,\n    :meth:`cache_path() <compiler_gym.cache_path>` is used as a fallback. Set\n    the environment variable :code:`$COMPILER_GYM_TRANSIENT_CACHE` to override\n    the default location.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    :param relpath: The relative path within the cache tree.\n\n    :return: An absolute path.\n    \"\"\"\n    forced = os.environ.get(\"COMPILER_GYM_TRANSIENT_CACHE\")\n    if forced:\n        return Path(forced) / relpath\n    elif Path(\"/dev/shm\").is_dir():\n        return Path(f\"/dev/shm/compiler_gym_{getpass.getuser()}\") / relpath\n    else:\n        # Fallback to using the regular cache.\n        return cache_path(relpath)\n", "path": "compiler_gym/util/runfiles_path.py"}], "after_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\"\"\"Module for resolving a runfiles path.\"\"\"\nimport os\nfrom getpass import getuser\nfrom pathlib import Path\n\n# NOTE(cummins): Moving this file may require updating this relative path.\n_PACKAGE_ROOT = Path(os.path.join(os.path.dirname(__file__), \"../../\")).resolve(\n    strict=True\n)\n\n\ndef runfiles_path(relpath: str) -> Path:\n    \"\"\"Resolve the path to a runfiles data path.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    Use environment variable COMPILER_GYM_RUNFILES=/path/to/runfiles if running\n    outside of bazel.\n\n    :param relpath: The relative path within the runfiles tree.\n\n    :return: An absolute path.\n    \"\"\"\n    # There are three ways of determining a runfiles path:\n    #   1. Set the COMPILER_GYM_RUNFILES environment variable.\n    #   2. Using the rules_python library that is provided by bazel. This will\n    #      fail if not being executed within a bazel sandbox.\n    #   3. Computing the path relative to the location of this file. This is the\n    #      fallback approach that is used for when the code has been installed\n    #      by setuptools.\n    runfiles_path = os.environ.get(\"COMPILER_GYM_RUNFILES\")\n    if runfiles_path:\n        return Path(runfiles_path) / relpath\n    else:\n        try:\n            from rules_python.python.runfiles import runfiles\n\n            return Path(\n                runfiles.Create().Rlocation(\n                    \"CompilerGym\" if relpath == \".\" else f\"CompilerGym/{relpath}\"\n                )\n            )\n        except (ModuleNotFoundError, TypeError):\n            return _PACKAGE_ROOT / relpath\n\n\ndef site_data_path(relpath: str) -> Path:\n    \"\"\"Return a path within the site data directory.\n\n    CompilerGym uses a directory to store persistent site data files in, such as benchmark datasets.\n    The default location is :code:`~/.local/share/compiler_gym`. Set the environment variable\n    :code:`$COMPILER_GYM_SITE_DATA` to override this default location.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    :param relpath: The relative path within the site data tree.\n\n    :return: An absolute path.\n    \"\"\"\n    # NOTE(cummins): This function has a matching implementation in the C++\n    # sources, compiler_gym::service::getSiteDataPath(). Any change to behavior\n    # here must be reflected in the C++ version.\n    forced = os.environ.get(\"COMPILER_GYM_SITE_DATA\")\n    if forced:\n        return Path(forced) / relpath\n    elif os.environ.get(\"HOME\"):\n        return Path(\"~/.local/share/compiler_gym\").expanduser() / relpath\n    else:\n        return Path(f\"/tmp/compiler_gym_{getuser()}/site_data\") / relpath\n\n\ndef cache_path(relpath: str) -> Path:\n    \"\"\"Return a path within the cache directory.\n\n    CompilerGym uses a directory to cache files in, such as downloaded content.\n    The default location for this cache is :code:`~/.cache/compiler_gym`. Set\n    the environment variable :code:`$COMPILER_GYM_CACHE` to override this\n    default location.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    :param relpath: The relative path within the cache tree.\n\n    :return: An absolute path.\n    \"\"\"\n    forced = os.environ.get(\"COMPILER_GYM_CACHE\")\n    if forced:\n        return Path(forced) / relpath\n    elif os.environ.get(\"HOME\"):\n        return Path(\"~/.cache/compiler_gym\").expanduser() / relpath\n    else:\n        return Path(f\"/tmp/compiler_gym_{getuser()}/cache\") / relpath\n\n\ndef transient_cache_path(relpath: str) -> Path:\n    \"\"\"Return a path within the transient cache directory.\n\n    The transient cache is a directory used to store files that do not need to\n    persist beyond the lifetime of the current process. When available, the\n    temporary filesystem :code:`/dev/shm` will be used. Else,\n    :meth:`cache_path() <compiler_gym.cache_path>` is used as a fallback. Set\n    the environment variable :code:`$COMPILER_GYM_TRANSIENT_CACHE` to override\n    the default location.\n\n    No checks are to made to ensure that the path, or the containing directory,\n    exist.\n\n    :param relpath: The relative path within the cache tree.\n\n    :return: An absolute path.\n    \"\"\"\n    forced = os.environ.get(\"COMPILER_GYM_TRANSIENT_CACHE\")\n    if forced:\n        return Path(forced) / relpath\n    elif Path(\"/dev/shm\").is_dir():\n        return Path(f\"/dev/shm/compiler_gym_{getuser()}\") / relpath\n    else:\n        # Fallback to using the regular cache.\n        return cache_path(relpath)\n", "path": "compiler_gym/util/runfiles_path.py"}]}