Skip to content

Commit

Permalink
snap: fix err detection from exec.LookPath() to work with go-1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Feb 16, 2021
1 parent 812d900 commit 06b2607
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/snap/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (

"github.com/godbus/dbus"
"github.com/jessevdk/go-flags"
"golang.org/x/xerrors"

"github.com/snapcore/snapd/client"
"github.com/snapcore/snapd/dbusutil"
Expand Down Expand Up @@ -1176,8 +1175,12 @@ func (x *cmdRun) runSnapConfine(info *snap.Info, securityTag, snapApp, hook stri
return x.runCmdUnderGdb(cmd, envForExec)
} else if x.useGdbserver() {
if _, err := exec.LookPath("gdbserver"); err != nil {
if xerrors.Is(err, exec.ErrNotFound) {
return fmt.Errorf("please install gdbserver on your system")
// TODO: use xerrors.Is(err, exec.ErrNotFound) once
// we moved off from go-1.9
if execErr, ok := err.(*exec.Error); ok {
if execErr.Err == exec.ErrNotFound {
return fmt.Errorf("please install gdbserver on your system")
}
}
return err
}
Expand Down

0 comments on commit 06b2607

Please sign in to comment.