diff --git a/cmd/run.go b/cmd/run.go index cf9fab3e..747535b5 100755 --- a/cmd/run.go +++ b/cmd/run.go @@ -132,7 +132,10 @@ func run(cmd *cobra.Command, args []string) error { } executablePath, err := exec.LookPath(parsedCommand[0]) if err != nil { - return fmt.Errorf("could not find executable %s", parsedCommand[0]) + if _, err := os.Stat(parsedCommand[0]); os.IsNotExist(err) { + return fmt.Errorf("could not find executable %s", parsedCommand[0]) + } + return fmt.Errorf("could not find executable %s, does it have executable privileges?", parsedCommand[0]) } // Executable needs to be defined with an absolute path since it will be run within the context of repositories if !filepath.IsAbs(executablePath) { diff --git a/internal/multigitter/print.go b/internal/multigitter/print.go index 5273f5c2..5f5aa8cb 100755 --- a/internal/multigitter/print.go +++ b/internal/multigitter/print.go @@ -101,7 +101,7 @@ func (r Printer) runSingleRepo(ctx context.Context, repo domain.Repository) erro err = cmd.Run() if err != nil { - return err + return transformExecError(err) } return nil diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go index a87070aa..4264086b 100755 --- a/internal/multigitter/run.go +++ b/internal/multigitter/run.go @@ -197,7 +197,7 @@ func (r Runner) runSingleRepo(ctx context.Context, repo domain.Repository) (doma err = cmd.Run() if err != nil { - return nil, err + return nil, transformExecError(err) } if changed, err := sourceController.Changes(); err != nil { diff --git a/internal/multigitter/shared.go b/internal/multigitter/shared.go index 32a68f40..9a1fd7c6 100644 --- a/internal/multigitter/shared.go +++ b/internal/multigitter/shared.go @@ -1,5 +1,21 @@ package multigitter +import ( + "syscall" + + "github.com/pkg/errors" +) + type urler interface { URL() string } + +func transformExecError(err error) error { + var sysErr syscall.Errno + if ok := errors.As(err, &sysErr); ok { + if sysErr.Error() == "exec format error" { + return errors.New("the script or program is in the wrong format") + } + } + return err +}