Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-88881

Default MacOS Bazel cache directory to non-tmp location

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Build

      Bazel defaults to using /private/tmp/var as a cache location, which is cleared upon MacOS upgrade. Default to a cache path that isn't tmp to retain the same functionality we supported in SCons and avoid confusion around missing files after reboot.

      https://apple.stackexchange.com/questions/22694/private-tmp-vs-private-var-tmp-vs-tmpdir/454795#454795

      Context: https://mongodb.slack.com/archives/CQDQ9R413/p1712052807975879 

      mathias: I've run into an issue with the bazel setup, at least on macos. It seems like bazel-out ends up being a symlink to a directory that gets blown away on reboot. The initial issue is that rebuilding after a reboot fails with an error about a directory not existing.  If I rm the symlink I can build again, However that causes bazel to start from scratch, including redownloading python, etc. We should probably ensure that bazel puts its data in a more durable location, and avoid tmp directories. This could be a real problem in environments where tmp directories are ram disks since we don't want build artifacts to be forced into ram (even if we want the current build to be in the OS cache). I don't know if macos does that, but I know some linux distros do, and it would certainly explain why it is blown away on reboot.
      
      [0/2950 (  0%) 0.326s] Running bazel build
      ninja: error: mkdir(/Users/mstearn/mongo/bazel-out/darwin_arm64-dbg): No such file or directory
      ninja: build stopped: .
      > ll bazel-out
      lrwxr-xr-x  1 mstearn  staff    92B Mar 26 13:42 bazel-out@ -> /private/var/tmp/_bazel_mstearn/1f97a09d238b0434d3147de863921dd0/execroot/__main__/bazel-out
      > ll bazel-out/
      ls: bazel-out/: No such file or directory 

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            zack.winter@mongodb.com Zack Winter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: