Cannot access DerivedData folder when building

Hello.
Our project is running on CircleCI 1.0. When I trigger a build using Web API I get a strange access rights issue when the build starts. Has someone faced such a problem?:

_Couldn't create workspace arena folder '/Users/distiller/Library/Developer/Xcode/DerivedData/<project name-hashvalue>': You don’t have permission to save the file <project name-hashvalue> in the folder DerivedData._
_Couldn't create module cache folder '/Users/distiller/Library/Developer/Xcode/DerivedData/ModuleCache': Unable to create directory: /Users/distiller/Library/Developer/Xcode/DerivedData/ModuleCache (Permission denied)_
_Couldn't update module cache session file '/Users/distiller/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation': The folder “Session.modulevalidation” doesn’t exist._

This is a pretty common issue in CI.

The key thing to remember is that the build runs as the distiller user on MacOS builds (and typically ubunutu on Linux builds). These users only have write permissions in their $HOME folders and places like /tmp. This is not unique to CI, this is true by default in almost all Linux/Unix environments.

Solution

  1. Store things inside of a folder that the user running the build has permissions to.
  2. Change the ownership of the directory with the chown command before trying to write to it.

I think #1 is the best approach. If you decide to go with #2 then a command like this should work in both MacOS and Linux builds.

chown -R $USER:$USER /path/to/directory

$USER is a global environment variable that refers to the current logged in user.

/path/to/directory should be replaced with the path to where you want to write to.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.