The use of os.userInfo().homedir depends on a /etc/passwd entry, which in some hardened setups may not exist.  os.homedir(), which just depends on $HOME, is more more likely to be right.
For example, it thinks my user's home is / which is breaking things when my runtime home is actually /run/github-runner/runner-2.