RSS 2025-12-06 03:47
libraries

Getting permissions errors on MacOS

来源:Reddit r/golang

I recently bought a MacBook that I use almost exclusively for writing and running code, mostly in go.

Everything was working just fine until today. I haven't used my macbook in about a week. Today I opened it and woke it up and got a message saying that it has rebooted due to a system error, but everything seemed fine.

Anyway, I went to run one of my programs using "go run" and it gave me a permissions error (permission denied), saying that it couldn't create a temp folder in /var/folders/zz/zy<something>/T. It's trying to create a directory called go-build<something>, presumably as a working directory for the build. I get a similar error if I try to run any go command at all (eg, go env)

This worked fine up until last week and I haven't changed or updated anything -- my laptop has been closed and asleep since then. A reboot didn't help. The T directory it's trying to write to is owned by root/wheel and has mode 800 so it makes sense that only root can create directories there.

Is it normal for go to create its temp working directory there? I'm trying to figure out if go somehow got misconfigured or if there's something wrong with my Mac. As a workaround, I am able to run go using sudo and chown any output files back to me, but obviously this isn't a great solution. I wonder if anyone has seen anything similar on macos, and how you've fixed it? I've only had this laptop for a couple of months but at my last job I used go on MacOS (for about 3-4 years) and never had this issue pop up. Before that I've only ever used Linux.

It all seems strange because I didn't change it reconfigure anything and everything used to work just fine.

submitted by /u/Keith_13
[link] [comments]