diff --git a/cli/main.go b/cli/main.go index 64a60ce2d..1d769e1a1 100644 --- a/cli/main.go +++ b/cli/main.go @@ -192,8 +192,10 @@ func execMoby(ctx context.Context) { cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { if exiterr, ok := err.(*exec.ExitError); ok { + fmt.Fprintln(os.Stderr, exiterr.Error()) os.Exit(exiterr.ExitCode()) } + fmt.Fprintln(os.Stderr, err) os.Exit(1) } os.Exit(0) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index dd43d1376..8b01af57c 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -31,6 +31,7 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "testing" "time" @@ -65,6 +66,19 @@ func (s *E2eSuite) TestContextDefault() { }) } +func (s *E2eSuite) TestSetupError() { + It("should display an error if cannot shell out to docker-classic", func() { + err := os.Setenv("PATH", s.BinDir) + Expect(err).To(BeNil()) + err = os.Remove(filepath.Join(s.BinDir, "docker-classic")) + Expect(err).To(BeNil()) + output, err := s.NewDockerCommand("ps").Exec() + Expect(output).To(ContainSubstring("docker-classic")) + Expect(output).To(ContainSubstring("not found")) + Expect(err).NotTo(BeNil()) + }) +} + func (s *E2eSuite) TestLegacy() { It("should list all legacy commands", func() { output := s.NewDockerCommand("--help").ExecOrDie()