zsh: can't create temp file for here document: permission denied

7 Nov 2022 19:58 zsh macos

Problems with zsh on macOS.

zsh: can't create temp file for here document: permission denied

The permissions on /tmp, which is a symlink to /tmp/private are kinda screwy on my macOS installation:

% ls -ld /tmp
lrwxr-xr-x@ 1 root  wheel  11 24 Aug 09:59 /tmp@ -> private/tmp
% ls -ld /private/tmp
drwxr-xr-x  13 root  admin  416  7 Nov 19:58 /private/tmp/

Are they supposed to look like that? Dunno. I don’t have another Mac to compare with. Various things on the Internet suggest just shotgunning a chmod 777 in there, but I’m not happy with that.

The correct answer, as far as I can tell, is this:

export TMPPREFIX="$TMPDIR"

Zsh uses $TMPPREFIX (which defaults to /tmp/zsh), but everything else uses $TMPDIR (which appears to be set somewhat sanely).