Unity and Mac OSX File permissions Error

I came across a very odd problem this morning from a lecturer who was trying to make some Unity coursework. Its turns out in the end to be both a Mac OSX File permissions problem AND a Unity problem.

 

No matter how they were opened we always came back to the same problem… There wasn’t the right permissions to copy files in and out of the Temp folders. Even if you tried to Save the Project you got the same “Moving File Failed” error. After a hack about in the forums it seems that Unity doesn’t like network drives so we copied the files to the local /Users/Shared area. The problem manifested itself in the same way… There are lots of forum entries for this type of problem but no real satisfactory answers…. Time to dig deeper.

 

I start looking up Mac OSX file permissions and I am happily told that you can do it all from Finder and using Get Info.. Pah! that was no help and didn’t make a difference.

 

Then I find an entry talking about extended attributes. Ok, so it seems that when you copy a file from a network drive even to a local one, it still retains some of the network permissions for the file in its list of extended attributes…

 

You can view extended attribute using the xattr command in Terminal. If you know the extended attribute then you can use xattr –d “attributeName” to get rid of it. I didn’t see anything in particular so I used the cp -X command (again in Terminal) to strip out all attributes from the file.

 

eg cp -Xr OldUnityProject ./NewUnityProject

 

A follow up xattr reveals no added entries.. Super… So that sorted out the Mac OS side of the problem….Back to Unity!

 

Opened up Unity and the student project in the New directory. When I selected Build and Run however it still wanted to compile to the student’s original home area WHICH WE DID NOT HAVE PERMISSIONS FOR!!!! So, the first thing to do is to do File->Save Project… This time with the file permissions set properly it saves. Then when doing File->Build and Run as a final check, ensure the area where the built file is to be stored is where you think it is… i.e. local to the project.

 

And there you have it….

 

Easy really….