iron_go
iron_go copied to clipboard
darwin: config throws `Error getting home directory: exec: "sh": executable file not found in $PATH`
I've been experiencing this now for several months and a co-worker of mine sat down and traced this error all the way back to this line:
https://github.com/iron-io/iron_go/blob/master/config/homedir.go#L57
When building on Darwin it throws the error:
Error getting home directory: exec: "sh": executable file not found in $PATH
I found that if we modified the line to use an absolute path to the sh executable it works like following:
cmd := exec.Command("/bin/sh", "-c", "eval echo ~$USER")
I realize that as that function is Unix specific /bin/sh is not likely going to be the same across all platforms as such I have not submitted a PR.
Sorry, missed this one. Thanks for tracking that down. Going to try a few different things and will reference this issue when we find a solution.
upstream code has changed to grep /etc/passwd - https://github.com/mitchellh/go-homedir/blob/master/homedir.go
I could try updating to that and seeing if it works if you are not currently working on this @rdallman .
sure, worth syncing with upstream @nikhilm
FWIW i can't reproduce this in OS X Yosemite, Go 1.5 because it can successfully find sh even without the /bin prefix. @polds What "Darwin" are you using exactly?
homedir tries getent then falls back to the same shell approach. getent does not return a valid result on Mac (at least my mac), so it will lead to the same failure.
@nikhilm I'm now on El Capitan Go 1.5.1, at time of reporting I was on Yosemite Go 1.4.
We ran into an instance where calling os.Clearenv() can once again get this problem to present itself.
Thanks for the os.Clearenv() tip. I'll try with that.