can't write to /var/folders
ryandesign at macports.org
Wed Dec 26 17:50:24 PST 2012
On Dec 25, 2012, at 21:59, Robert Broome wrote:
> I use gfortran installed via macports. I am currently at gcc46, with gcc45 installed to support fortran-netcdf.
> When I try to compile a simple program (which has compiled on this machine several days ago), I get:
> gfortran -o sorttest sorttest.f95
> f951: fatal error: can’t open /var/folders/p8/s7gtynwj7_x___mlswzr7sp80000gn/T//ccnZNOg5.s for writing: Permission denied
> compilation terminated.
This strange-looking path within /var/folders is the value of the variable $TMPDIR, which is a variable programs like gfortran use to find a directory where they can write temporary files. $TMPDIR is supposed to be a directory unique to your user, and the randomness of the path is so that other users' programs on your computer cannot guess it (which would have security implications if they could).
> I don't know the implications of:
> I don't see how one even creates that.
Although the double slash looks untidy to you and me, it is not a problem; the OS combines any consecutive slashes into a single slash.
The double slash probably occurs because the authors of gfortran wanted to accommodate values of $TMPDIR that did not end with a slash, so they programmed their temporary filename to be something like "$TMPDIR/filename". The $TMPDIR variable on OS X does already end with a slash, thus resulting in an unattractive but harmless double slash.
> Obviously there is a permission problem.
> /var/folders/p8 is owned by root.
> drwxr-xr-x 5 rbroome staff 170 Dec 25 20:53 s7gtynwj7_x___mlswzr7sp80000gn/p8 is owned by user (me).
> directory p8 contains:
> drwxr-xr-x 2 rbroome staff 68 Dec 25 20:53 0 (this is a numeric 0, not a text O)
> drwx------ 8 rbroome staff 272 Dec 25 21:00 C
> drwx------ 8 rbroome staff 272 Dec 25 20:55 T
> the contents of T is:
> ll /var/folders/p8/s7gtynwj7_x___mlswzr7sp80000gn/T/
> total 8
> drwx------@ 2 rbroome staff 68 Dec 25 20:47 Cleanup At Startup
> drwx------@ 3 rbroome staff 102 Dec 25 20:56 com.apple.TextEdit
> drwx------@ 3 rbroome staff 102 Dec 25 20:53 com.apple.mail
> -rw------- 1 rbroome staff 59 Dec 25 20:23 xcrun_db
> Can anyone give me a suggestion on what to do to solve this compile error?
It does sound like a permissions problem, however all of the permissions and ownership you've shown above correspond to how they are on my system, so I don't see a problem there. Still, you could try logging out of your user account (Apple menu > Log Out Robert Broome) and logging back in; possibly OS X will delete and re-create these temporary directories at that time, and if so, then it should recreate them with appropriate permissions.
You could also try whether you are able to manually create files in that temporary directory.
More information about the macports-users