This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
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? |
ethanmick
added a commit
to virtyx-technologies/go-homedir
that referenced
this issue
Jan 24, 2018
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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: