DisposaBoy / GoSublime

A Golang plugin collection for SublimeText 3, providing code completion and other IDE-like features.
MIT License
3.42k stars 302 forks source link

GoSublime error: MarGo build failed #491

Closed ewmin3m closed 10 years ago

ewmin3m commented 10 years ago

Hello,

It seem that there was a new update pushed for GoSublime recently and I get the following error:

| GoSublime error: MarGo build failed | > This is possibly a bug or miss-configuration of your environment. | > For more help, please file an issue with the following build output | > at: https://github.com/DisposaBoy/GoSublime/issues/new | > or alternatively, you may send an email to: gosublime@dby.me | > | > | > cmd: ['/usr/local/opt/go/bin/go', 'build', '-v', '-x', '-o', 'gosublime.margo_r13.12.26-2_go1.1.2.exe', 'gosubli.me/margo'] | > stdout: WORK=/var/folders/n7/lv0xwzn94tq111bd27q5z1sr0000gn/T/go-build036616124 | > stderr: ../../../../GoSublime/src/gosubli.me/margo/broker.go:4:2: cannot find package "bufio" in any of: | > /usr/local/go/src/pkg/bufio (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/bufio (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/broker.go:5:2: cannot find package "bytes" in any of: | > /usr/local/go/src/pkg/bytes (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/bytes (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/common.go:5:2: cannot find package "encoding/base64" in any of: | > /usr/local/go/src/pkg/encoding/base64 (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/encoding/base64 (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/broker.go:6:2: cannot find package "encoding/json" in any of: | > /usr/local/go/src/pkg/encoding/json (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/encoding/json (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/package.go:5:2: cannot find package "errors" in any of: | > /usr/local/go/src/pkg/errors (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/errors (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/main.go:7:2: cannot find package "flag" in any of: | > /usr/local/go/src/pkg/flag (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/flag (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/common.go:7:2: cannot find package "fmt" in any of: | > /usr/local/go/src/pkg/fmt (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/fmt (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/common.go:8:2: cannot find package "go/ast" in any of: | > /usr/local/go/src/pkg/go/ast (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/go/ast (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/m_play.go:5:2: cannot find package "go/build" in any of: | > /usr/local/go/src/pkg/go/build (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/go/build (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/common.go:9:2: cannot find package "go/parser" in any of: | > /usr/local/go/src/pkg/go/parser (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/go/parser (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/common.go:10:2: cannot find package "go/printer" in any of: | > /usr/local/go/src/pkg/go/printer (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/go/printer (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/m_lint.go:6:2: cannot find package "go/scanner" in any of: | > /usr/local/go/src/pkg/go/scanner (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/go/scanner (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/common.go:11:2: cannot find package "go/token" in any of: | > /usr/local/go/src/pkg/go/token (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/go/token (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/config.go:7:2: cannot find package "io" in any of: | > /usr/local/go/src/pkg/io (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/io (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/autocompletecontext.go:9:2: cannot find package "io/ioutil" in any of: | > /usr/local/go/src/pkg/io/ioutil (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/io/ioutil (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/main.go:10:2: cannot find package "log" in any of: | > /usr/local/go/src/pkg/log (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/log (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/types/const.go:12:2: cannot find package "math/big" in any of: | > /usr/local/go/src/pkg/math/big (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/math/big (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/server.go:5:2: cannot find package "net" in any of: | > /usr/local/go/src/pkg/net (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/net (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/m_pkgdoc.go:7:2: cannot find package "net/http" in any of: | > /usr/local/go/src/pkg/net/http (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/net/http (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/client.go:7:2: cannot find package "net/rpc" in any of: | > /usr/local/go/src/pkg/net/rpc (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/net/rpc (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/m_pkgdoc.go:8:2: cannot find package "net/url" in any of: | > /usr/local/go/src/pkg/net/url (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/net/url (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/autocompletecontext.go:10:2: cannot find package "os" in any of: | > /usr/local/go/src/pkg/os (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/os (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/os_posix.go:8:2: cannot find package "os/exec" in any of: | > /usr/local/go/src/pkg/os/exec (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/os/exec (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/m_doc.go:7:2: cannot find package "path" in any of: | > /usr/local/go/src/pkg/path (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/path (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/autocompletecontext.go:11:2: cannot find package "path/filepath" in any of: | > /usr/local/go/src/pkg/path/filepath (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/path/filepath (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/config.go:10:2: cannot find package "reflect" in any of: | > /usr/local/go/src/pkg/reflect (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/reflect (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/margo/m_lint.go:9:2: cannot find package "regexp" in any of: | > /usr/local/go/src/pkg/regexp (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/regexp (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/autocompletecontext.go:12:2: cannot find package "runtime" in any of: | > /usr/local/go/src/pkg/runtime (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/runtime (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/autocompletecontext.go:13:2: cannot find package "sort" in any of: | > /usr/local/go/src/pkg/sort (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/sort (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/client.go:10:2: cannot find package "strconv" in any of: | > /usr/local/go/src/pkg/strconv (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/strconv (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/decl.go:10:2: cannot find package "strings" in any of: | > /usr/local/go/src/pkg/strings (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/strings (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/decl.go:11:2: cannot find package "sync" in any of: | > /usr/local/go/src/pkg/sync (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/sync (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/package.go:13:2: cannot find package "text/scanner" in any of: | > /usr/local/go/src/pkg/text/scanner (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/text/scanner (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/autocompletecontext.go:14:2: cannot find package "time" in any of: | > /usr/local/go/src/pkg/time (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/time (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/cursorcontext.go:6:2: cannot find package "unicode" in any of: | > /usr/local/go/src/pkg/unicode (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/unicode (from $GOPATH) | > ../../../../GoSublime/src/gosubli.me/something-borrowed/gocode/cursorcontext.go:7:2: cannot find package "unicode/utf8" in any of: | > /usr/local/go/src/pkg/unicode/utf8 (from $GOROOT) | > ~/Library/Application Support/Sublime Text 3/Packages/GoSublime/src/unicode/utf8 (from $GOPATH) | > exception: None | install state: busy | sublime.version: 3059 | sublime.channel: stable | about.ann: a13.12.26-1 | about.version: r13.12.26-2 | version: r13.12.26-2 | platform: osx-x64 | ~bin: ~/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/osx-x64/bin | margo.exe: ~bin/gosublime.margo_r13.12.26-2_go1.1.2.exe (missing) | go.exe: ~/Documents/programming/golang/go/bin/go (ok) | go.version: go1.1.2 | GOROOT: /usr/local/go | GOPATH: ~/Documents/programming/golang/go | GOBIN: (not set) (should usually be (not set)) | set.shell: [] | env.shell: /bin/bash | shell.cmd: ['/bin/bash', '-l', '-c', '${CMD}']

The issue that I see is that the value of GOROOT isn't the same as the one where I type go env in the command line:

GOARCH="amd64" GOBIN="" GOCHAR="6" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/KOJY/Documents/programming/golang/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.1.2/libexec" GOTOOLDIR="/usr/local/Cellar/go/1.1.2/libexec/pkg/tool/darwin_amd64" CC="gcc" GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common" CGO_ENABLED="1"

The updates have been working so far, it just seems this last one is causing problems.

Any help appreciated, Thanks !

DisposaBoy commented 10 years ago

AFAICS, you have multiple intallations of Go on your system. You should probably remove the one in /usr/local/opt/go/

ewmin3m commented 10 years ago

I removed the opt/ directory, because everything in this directory pointed to folders from the Cellar/ directory. I don't get why it's looking in /usr/local/go when the GOROOT specifies a different directory. I don't even have a go/ directory in usr/local...

I still have this issue after deleting the respective folder.

I actually re-installed sublime text 3 app and the GoSublime package and i go no build failed error. But once I closed and re-opened sublime again, the build failure re-appeared...

DisposaBoy commented 10 years ago

AFAIK, it has nothing to do with GS, ST3 or their versions. A go binary is found on you system and it's being used but is obviously the wrong one. The binary must surely exist at /usr/local/opt/go/bin/go because that's the command that got called and it didn't fail, it in fact resulted in a version detection of go1.1.2. Here is the list of default locations that are added to PATH https://github.com/DisposaBoy/GoSublime/blob/master/gosubl/sh.py#L333

ewmin3m commented 10 years ago

I updated and upgraded homebrew (im on a mac) and it updated go 1.2. When i start sublime now the error has changed to:

| GoSublime error: MarGo build failed | > This is possibly a bug or miss-configuration of your environment. | > For more help, please file an issue with the following build output | > at: https://github.com/DisposaBoy/GoSublime/issues/new | > or alternatively, you may send an email to: gosublime@dby.me | > | > | > cmd: ['/usr/local/opt/go/bin/go', 'build', '-v', '-x', '-o', 'gosublime.margo_r13.12.26-2_go1.1.2.exe', 'gosubli.me/margo'] | > stdout: ` | > stderr:go: cannot find GOROOT directory: /usr/local/go | > exception:None | install state: busy | sublime.version: 3059 | sublime.channel: stable | about.ann: a13.12.26-1 | about.version: r13.12.26-2 | version: r13.12.26-2 | platform: osx-x64 | ~bin: ~/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/osx-x64/bin | margo.exe: ~bin/gosublime.margo_r13.12.26-2_go1.1.2.exe (missing) | go.exe: ~/Documents/programming/golang/go/bin/go (ok) | go.version: go1.1.2 | GOROOT: /usr/local/go | GOPATH: ~/Documents/programming/golang/go | GOBIN: (not set) (should usually be(not set)`) | set.shell: [] | env.shell: /bin/bash | shell.cmd: ['/bin/bash', '-l', '-c', '${CMD}']

DisposaBoy commented 10 years ago

it's still using the wrong binary at ~/Documents/programming/golang/go/bin/go suggesting that something on your system is setting either GOROOT or GOPATH to ~/Documents/programming/golang/go or PATH to ~/Documents/programming/golang/go/bin ... you can open 9o and run the commands settings and env to see what your settings and environment vars look like

ewmin3m commented 10 years ago

Yes, it's because I wanted that specific location for the go install. I managed to solve it by creating a sym link to the existing path from usr/local/go.

Thanks for the help!

DisposaBoy commented 10 years ago

If you install go in a place that's not the default, you need to set GOROOT

mackdoyle commented 10 years ago

If you have installed Go using Homebrew, try setting the GoSublime environment using this in your GoSublime.sublime-settings - User.

"env": {
    "GOPATH": "$HOME/go",
    "GOROOT": "/usr/local/Cellar/go/1.3.1/libexec",
  },

GOPATH is the location of my Go workspace and GOROOT is the location of the Go source when installed through Homebrew. (change the version number to the version you have installed)

binarylogic commented 9 years ago

Adding /libexec worked for me.

heimawang commented 3 years ago

yes