Search code examples
macosgohomebrewgodoc

Golang is having permission issues on my new Mac, fresh install


a little bit of context

I have been working on Golang for almost 2 years now, just yesterday I got a Mac, I'm new on this OS, previously I have only worked Golang on linux, both Ubuntu and arch and the process has been straightforward, as it seems on mac according to most posts.

The Issue

Rn I notices that when trying to run commands for my work projects I was receiving permission errors, I tried to use chmod to provide elevated access, but nothing seems to work, I have updated path variables, uninstall golang, install other versions, use brew even, but the same error always shows up,

go mod tidy
example.com/m: open /Users/andrewalizaga/Library/Caches/go-build/78/78eb7bcc7e29eb28c3e9df7a741641913f745d9b271d51e223c70e81e0e11def-d: permission denied

this is what I always get, seems to be about cache and files being locked, this one appear when I tried to run a brand new project, so it does not seem to be about my work related stuff. I appreciate any help, thanks in advance


Solution

  • Ok, so now I got it... kinda

    I just manage to fix it by manually giving my admin use some extra access to specific folders, the error was popping with a library folder and a cache folder so using the following command

    sudo chown -R $username /Users/$username/Library
    

    I was able to pass this error and just it works just as in Linux, that part that bugs me still is not knowing why was this needed in the first place, my user is admin and it's a fresh install, all the documentation I read made no mention of needing to provide this manually to your user, I'm guessing MacOS has a distinction between root and admin as well, but I still don't see why this affected on my case