Skip to content
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

cmd/go: helpful error messages when hg, git, svn, bzr not found #4652

Closed
bradfitz opened this issue Jan 12, 2013 · 4 comments
Closed

cmd/go: helpful error messages when hg, git, svn, bzr not found #4652

bradfitz opened this issue Jan 12, 2013 · 4 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

If a vcs tool like hg, git, svn, bzr is not found, cmd/go should explain to the user
what to install.

See confusion at https://plus.google.com/u/0/115056313943520401920/posts/Xvmwe76BJMS

vcs.go currently has just:

// run1 is the generalized implementation of run and runOutput.                         
                                                                                        
                                   
func (v *vcsCmd) run1(dir string, cmdline string, keyval []string, verbose bool)
([]byte, error) {
        m := make(map[string]string)
        for i := 0; i < len(keyval); i += 2 {
                m[keyval[i]] = keyval[i+1]
        }
        args := strings.Fields(cmdline)
    for i, arg := range args {
                args[i] = expand(m, arg)
        }

        cmd := exec.Command(v.cmd, args...)
        cmd.Dir = dir
        if buildX {
                fmt.Printf("cd %s\n", dir)
        fmt.Printf("%s %s\n", v.cmd, strings.Join(args, " "))
        }
        var buf bytes.Buffer
        cmd.Stdout = &buf
    cmd.Stderr = &buf
        err := cmd.Run()
        out := buf.Bytes()
        if err != nil {
                if verbose || buildV {
                        fmt.Fprintf(os.Stderr, "# cd %s; %s %s\n", dir, v.cmd, strings.Join(args, " "))
                        os.Stderr.Write(out)
        }
                return nil, err
        }
        return out, nil
}

We are more helpful in at at least one other case, as precedent:

        if toolIsWindows && toolName == "pprof" {
            args = append([]string{"perl", toolPath}, args[1:]...)
            var err error
                toolPath, err = exec.LookPath("perl")
                if err != nil {
                        fmt.Fprintf(os.Stderr, "go tool: perl not found\n")
                        setExitStatus(3)
            return
                }
        }
@gopherbot
Copy link

Comment 1 by jimmyzelinskie:

I think it already has a pretty clear message. What else would you suggest? Simply
adding another line like:
fmt.Fprintf(os.Stderr, "You most likely need to install %s", vcs.name)

@bradfitz
Copy link
Contributor Author

Comment 2:

See comments in the pending review at https://golang.org/cl/7094049/

@minux
Copy link
Member

minux commented Jan 27, 2013

Comment 3:

Issue #4710 has been merged into this issue.

@bradfitz
Copy link
Contributor Author

Comment 4:

This issue was closed by revision 56517ae.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants