New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exec.Run does not return exec.ErrNotFound error #18
Comments
Ah darn. Yes, we should just do a string check for this unfortunately. :( |
@mitchellh Any update on this? |
As explained here: mitchellh#18 The exec.ErrNotFound error is returned, but this error is wrapped by exec.Error() so the returned error will never be exec.ErrNotFound.
Another alternative is:
|
I just hit this problem and had to track it down to a bit to find it coming from this library while I run my binary in a completely empty env. Is there no movement on this bug? Seems like a library that is trying to abstract finding the user homedir should probably be able to work around this case as well. |
Another alternative is to ignore any kind of error so the final attempt to use the shell to cd and pwd can play out. This would mirror the darwin case where only a chain of successful steps leads to an early return. Just posting this for folks who are considering cloning the repo themselves. |
I don't have getent on my system, so the dirUnix function failed to execute it. It checks (https://github.com/mitchellh/go-homedir/blob/master/homedir.go#L87) if the exec.ErrNotFound error is returned, but this error is wrapped by exec.Error() so the returned error will never be exec.ErrNotFound.
The actual returned error message is:
exec: "getent": executable file not found in $PATH
, whereas it expected the following:executable file not found in $PATH
.A fix would be
if strings.HasSufix(err.Error(), err.ErrNotFound.Error()) {
.The text was updated successfully, but these errors were encountered: