Skip to content

More "couldn't create cache file '/var/folders/..." on macOS errors #6460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anta40 opened this issue Apr 5, 2025 · 7 comments
Open

More "couldn't create cache file '/var/folders/..." on macOS errors #6460

anta40 opened this issue Apr 5, 2025 · 7 comments

Comments

@anta40
Copy link

anta40 commented Apr 5, 2025

I'm on M2 Mac (macOS 15.4). Started to experience these error after trying to build recent base and async on OCaml 5.3.0.
ar: error: couldn't create cache file '/var/folders/xx/xxxxxxxxxxx/T/xcrun_db-xxxxxx

Only opam (v.2.2.1) was installed via homebrew, the rest (ocaml, dune etc) were installed via opam.

Here are my tickets:
Fail to install async on Ocaml 5.3.0
Failed to build base.v0.17.1 on Mac M2: unsupported option '-mpopcnt' for target 'arm64-apple-darwin24.3.0

Found some related tickets, and my impression so far is there's no clear solution, yet. E.g:
a possible regression on macOS /var/folders permission problem
Failure writing temporary files in MacOS X's /var/folders
Make the macOS sandbox stricter to workaround a macOS bug

I tried using sandbox_exec.sh... well it didn't work:

$ ./sandbox.sh
./sandbox_exec.sh: line 69: $1: unbound variable

Wonder if there's other possible solution.

@kit-ty-kate
Copy link
Member

The sandbox script requires arguments. For example: ~/.opam/opam-init/hooks/sandbox.sh build ls will execute the ls command under the sandbox.

As for the issue:

  • does the command above work without showing the error?
  • do you have ccache installed? (ccache -k cache_dir)

It seems peculiar that you're only seeing these with some janestreet packages, i'm not sure what would cause this only for those.

@anta40
Copy link
Author

anta40 commented Apr 6, 2025

  • does the command above work without showing the error?

Works fine

$ ./sandbox_exec.sh build uname
Darwin
$ ./sandbox_exec.sh build ls
sandbox_exec.sh	sandbox.sh	sandbox.sh.hash
$ ./sandbox_exec.sh build date
Sun Apr  6 11:54:03 WIB 2025
  • do you have ccache installed? (ccache -k cache_dir)

No

@kit-ty-kate
Copy link
Member

I was able to reproduce locally. Every packages are affected, not just janestreet ones. I have a workaround while we release opam 2.3.1: https://discuss.ocaml.org/t/cant-install-async-0-17-0-on-macos-15-4/16468/3

@kit-ty-kate
Copy link
Member

In the end my local reproduction was a fluke (i already had local changes in my sandbox script and i simply forgot to clean them before testing)

To help me understand what's happening once again and make sure the workaround is the right one, would you be able to run these commands:

opam init --reinit -ni
opam reinstall core_unix

This should fail with the couldn't create cache file errors. If it doesn't, please do tell.
If this fail as expected, would you be able to retry after an brew upgrade. Given your local version of opam is 2.2.1, i expect that many of your brew packages are outdated. If this fixes your issue, could you list the packages that were upgraded?
If this still fails, could you show the result of env? This will help me figure out what's going on.

To fix your setup temporarily again, you can reapply the workaround afterwards.

@kit-ty-kate
Copy link
Member

also, what does xcode-select -p give you?

@anta40
Copy link
Author

anta40 commented Apr 15, 2025

Sorry for the late reply. After installing the latest core_unix (v0.17.1), no issue with installing async.

@kit-ty-kate
Copy link
Member

I know, but since i gave you a workaround in https://discuss.ocaml.org/t/cant-install-async-0-17-0-on-macos-15-4/16468 it works for you but i still don't know the reason of your problem in the first place. For me to be able to close this issue i must understand it and understand its fix better, so we can distribute it in a release.

Would you be able to do the tests i asked you after reverting back to the previous state of sandbox script (per my diff in the discuss post) when you have some time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants