Caddy: Improve local build instructions

Created on 27 Aug 2017  路  12Comments  路  Source: caddyserver/caddy

The instructions found at https://github.com/mholt/caddy#install indicate that to build locally you should:

  1. go get github.com/mholt/caddy/caddy
  2. cd $GOPATH/src/github.com/mholt/caddy/caddy
  3. go run build.go

Here's what happens when I do that:

ubuntu@ip-172-26-11-136:~/src$ go get github.com/mholt/caddy/caddy
ubuntu@ip-172-26-11-136:~$ cd go/
ubuntu@ip-172-26-11-136:~/go$ cd src/github.com/mholt/caddy/caddy
ubuntu@ip-172-26-11-136:~/go/src/github.com/mholt/caddy/caddy$ go run build.go
build.go:27:2: cannot find package "github.com/caddyserver/buildworker" in any of:
    /home/ubuntu/go/src/github.com/mholt/caddy/vendor/github.com/caddyserver/buildworker (vendor tree)
    /snap/go/727/src/github.com/caddyserver/buildworker (from $GOROOT)
    /home/ubuntu/go/src/github.com/caddyserver/buildworker (from $GOPATH)
documentation

Most helpful comment

@arahmanhamdy Yeah, that's a different issue that's already fixed on master, it was fixed a day or two ago. Still need to figure out what to do about build tag though.

All 12 comments

Oops. Kind of surprising go get doesn't get the dependency for build.go. 馃 I'll set up a VM and experiment with this.

For reproduction, this was on a fresh Ubuntu 16.04 AWS instance. All I'd done was sudo apt update && sudo apt upgrade and then sudo snap install --classic go.

Ohhh it's because of the build tag on build.go: // +build dev

Now, to figure out what to do about this. go get -tags dev won't work because there are two main functions in that package. (I did this because it seemed strange to have the build program in a folder different from the main function where you would run go build or go install...)

Even when run go get github.com/caddyserver/buildworker explicitly, the repo isn't found!
seems that there is a problem with caddyserver/buildworker repo and it was changed to github.com/caddyserver/builds

@arahmanhamdy Yeah, that's a different issue that's already fixed on master, it was fixed a day or two ago. Still need to figure out what to do about build tag though.

I believe i got the same issue

go run build.go -goos=linux  
build.go:27:2: cannot find package "github.com/caddyserver/builds" in any of:
        /root/golang/packages/src/github.com/mholt/caddy/vendor/github.com/caddyserver/builds (vendor tree)
        /usr/local/go/src/github.com/caddyserver/builds (from $GOROOT)
        /root/golang/packages/src/github.com/caddyserver/builds (from $GOPATH)
  • CentOS 7.3
  • Go 1.9
go env 
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/golang/packages"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="ccache"
GOGCCFLAGS="gcc -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build841778279=/tmp/go-build -gno-record-gcc-switches"
CXX="ccache"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

Yeah, the problem is that go get only gets dependencies for files included by the build tag, and the "dev" build tag is not a default tag. I need to think this through some more :) but for now, go run build.go will build Caddy (but you'll have to go get github.com/caddyserver/builds first). I might have to move it to a different folder all by itself... sigh. We'll see.

k that works though we loose the version

caddy -version
Caddy (untracked dev build)

not a GO programmer so not sure but couldn't you add another flag to build.go so it could override the dev tag ? i.e. -gobuild=

// build.go automates proper versioning of caddy binaries.
// Use it like:   go run build.go
// You can customize the build with the -goos, -goarch, and
// -goarm CLI options:   go run build.go -goos=windows

We can now close this issue since the build instructions are current now, right?

They are current, but I think I want a better solution.

This is now resolved thanks to Go modules and new build instructions for v2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dafanasiev picture dafanasiev  路  3Comments

xfzka picture xfzka  路  3Comments

la0wei picture la0wei  路  3Comments

klaasel picture klaasel  路  3Comments

lorddaedra picture lorddaedra  路  3Comments