On Mac OS X we obtain the path for user.home with getpwuid(). Normally this will return /Users/<username>. However, if an application is signed and running in an OS X sandboxed environment this path is not accessible to the application, which must run in a container. In that case user.home should return the application's sandbox directory.
The easy way to fix this is use NSHomeDirectory(), which does the right thing in a sandboxed or non-sandboxed environment. Likewise, NSUserName() is a better choice for getting the current user name.