I can't build golang

609 views
Skip to first unread message

vox...@gmail.com

unread,
Oct 25, 2016, 10:32:03 AM10/25/16
to golang-nuts
I can't build golang due to cycle problem.

### What version of Go are you using (`go version`)?
The version on my pc is go version go1.7.1 darwin/amd64, but i downloaded a fresh version from git.

### What operating system and processor architecture are you using (`go env`)?
 ```
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/voxsim/Projects/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.1/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bt/fmr6z5wx2b9b2x9w51y2m_300000gn/T/go-build667588921=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
 ```

### my env variables
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.dJIR793aPj/Render
COLORFGBG=7;0
ITERM_PROFILE=Default
XPC_FLAGS=0x0
PWD=/Users/voxsim/Projects/go/src
SHELL=/bin/zsh
SECURITYSESSIONID=186ee
TERM_PROGRAM_VERSION=3.0.10
TERM_PROGRAM=iTerm.app
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/voxsim/.bin:/Users/voxsim/gopath/bin
COMMAND_MODE=unix2003
TERM=xterm-256color
HOME=/Users/voxsim
TMPDIR=/var/folders/bt/fmr6z5wx2b9b2x9w51y2m_300000gn/T/
USER=voxsim
XPC_SERVICE_NAME=0
LOGNAME=voxsim
ITERM_SESSION_ID=w0t2p1:22F762D5-BC47-4939-B825-1E5B2A641E1F
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
SHLVL=1
OLDPWD=/Users/voxsim/Projects/go
ZSH=/Users/voxsim/.oh-my-zsh
GOPATH=/Users/voxsim/gopath
EDITOR=nvim
DISABLE_AUTO_TITLE=true
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
ZSH_TMUX_TERM=screen-256color
_ZSH_TMUX_FIXED_CONFIG=/Users/voxsim/.oh-my-zsh/plugins/tmux/tmux.extra.conf
LC_CTYPE=UTF-8
_=/usr/bin/env

### What did you do?
After I checkout the project in ~/Projects/go e I read [here](https://golang.org/doc/contribute.html).
 ```
I setted GOROOT_BOOTSTRAP to /usr/local because my go installation is in /usr/local/bin/go:
export GOROOT_BOOTSTRAP=/usr/local
./all.bash
 ```

First result:
 ```
##### Building Go bootstrap tool.
cmd/dist
cmd/dist/build.go:8:2: cannot find package "bytes" in any of:
/usr/local/src/bytes (from $GOROOT)
/Users/voxsim/gopath/src/bytes (from $GOPATH)
cmd/dist/build.go:9:2: cannot find package "encoding/json" in any of:
/usr/local/src/encoding/json (from $GOROOT)
/Users/voxsim/gopath/src/encoding/json (from $GOPATH)
cmd/dist/test.go:9:2: cannot find package "errors" in any of:
/usr/local/src/errors (from $GOROOT)
/Users/voxsim/gopath/src/errors (from $GOPATH)
cmd/dist/build.go:10:2: cannot find package "flag" in any of:
/usr/local/src/flag (from $GOROOT)
/Users/voxsim/gopath/src/flag (from $GOPATH)
cmd/dist/build.go:11:2: cannot find package "fmt" in any of:
/usr/local/src/fmt (from $GOROOT)
/Users/voxsim/gopath/src/fmt (from $GOPATH)
cmd/dist/util.go:10:2: cannot find package "io" in any of:
/usr/local/src/io (from $GOROOT)
/Users/voxsim/gopath/src/io (from $GOPATH)
cmd/dist/test.go:12:2: cannot find package "io/ioutil" in any of:
/usr/local/src/io/ioutil (from $GOROOT)
/Users/voxsim/gopath/src/io/ioutil (from $GOPATH)
cmd/dist/test.go:13:2: cannot find package "log" in any of:
/usr/local/src/log (from $GOROOT)
/Users/voxsim/gopath/src/log (from $GOPATH)
cmd/dist/build.go:12:2: cannot find package "os" in any of:
/usr/local/src/os (from $GOROOT)
/Users/voxsim/gopath/src/os (from $GOPATH)
cmd/dist/build.go:13:2: cannot find package "os/exec" in any of:
/usr/local/src/os/exec (from $GOROOT)
/Users/voxsim/gopath/src/os/exec (from $GOPATH)
cmd/dist/build.go:14:2: cannot find package "path/filepath" in any of:
/usr/local/src/path/filepath (from $GOROOT)
/Users/voxsim/gopath/src/path/filepath (from $GOPATH)
cmd/dist/test.go:17:2: cannot find package "regexp" in any of:
/usr/local/src/regexp (from $GOROOT)
/Users/voxsim/gopath/src/regexp (from $GOPATH)
cmd/dist/util.go:15:2: cannot find package "runtime" in any of:
/usr/local/src/runtime (from $GOROOT)
/Users/voxsim/gopath/src/runtime (from $GOPATH)
cmd/dist/build.go:15:2: cannot find package "sort" in any of:
/usr/local/src/sort (from $GOROOT)
/Users/voxsim/gopath/src/sort (from $GOPATH)
cmd/dist/main.go:11:2: cannot find package "strconv" in any of:
/usr/local/src/strconv (from $GOROOT)
/Users/voxsim/gopath/src/strconv (from $GOPATH)
cmd/dist/build.go:16:2: cannot find package "strings" in any of:
/usr/local/src/strings (from $GOROOT)
/Users/voxsim/gopath/src/strings (from $GOPATH)
cmd/dist/build.go:17:2: cannot find package "sync" in any of:
/usr/local/src/sync (from $GOROOT)
/Users/voxsim/gopath/src/sync (from $GOPATH)
cmd/dist/test.go:21:2: cannot find package "time" in any of:
/usr/local/src/time (from $GOROOT)
/Users/voxsim/gopath/src/time (from $GOPATH)
 ```

I setted the GOPATH to the project:
 ```
export GOPATH=~/Projects/go
./all.bash
 ```

second result:
 ```
cmd/dist
import cycle not allowed
package cmd/dist
imports bytes
imports errors
imports runtime
imports runtime/internal/atomic
imports unsafe
imports runtime
 ```

Did i do something wrong?

I already open an issue in the github project (https://github.com/golang/go/issues/17581#issuecomment-256040098) but as ianlancetaylor pointed I did something wrong. Can someone help me? I did not set any GOROOT env variables. 
Is it possible to build the source of golang without installing before go?

Thanks,
voxsim

Dave Cheney

unread,
Oct 25, 2016, 11:38:40 AM10/25/16
to golang-nuts
It looks like you have many conflicting versions of Go all smoshed on your machine at the moment.

You proably have something from homebrew; uninstall that first. Then look in /usr/local/go and remove that. Check /etc/paths.d for anything that is adding a go version to your path and remove that.

*** DO NOT SET GOROOT *** If you find GOROOT set, unset it, do not continue until you are sure that GOROOT is not present in your terminals environment.

Then, when you have removed all the versions of Go on your computer you can start again.

Download this https://golang.org/doc/install?download=go1.7.3.darwin-amd64.tar.gz, and unpack it somewhere, set the environment variable GOROOT_BOOTSTRAP to point to the place where you unpacked that.

Then download the source for the version of go you want to build, https://golang.org/doc/install/source?download=go1.7.3.src.tar.gz, and unpack that somewhere, cd into that directory, then into src/, then call ./make.bash (or ./all.bash if you want to run the tests)

Dave
Reply all
Reply to author
Forward
0 new messages