Glide: GOPATH in 1.6 seems to expect ./src

Created on 19 Feb 2016  路  7Comments  路  Source: Masterminds/glide

I'm using docker's golang:1.6 image and the latest release of glide.

When I use glide install, a vendor directory is created that looks like:

vendor/
  - github.com/
      ...

If I set my GOPATH to that vendor directory, I see go build attempting to search vendor/src/github.com... rather than vendor/github.com...

I'm doing the same thing that I did previously using GO15VENDOREXPERIMENT=1 in go 1.5, but it's not working. Moving everything into a src directory within vendor seems to allow the build to complete.

Most helpful comment

@DavidJFelix thanks for sharing your Dockerfile. I see what's going on.

The GOPATH cannot be a vendor/ directory. This is hard coded into Go. You need something like...

WORKDIR /go/src/app

COPY ./gosrc /go/src/app
RUN glide install
RUN go build

The GOPATH here is /go. The GOPATH is required to have a directory inside named src where your source lives. The vendor/ directory is inside your source. This is non-negotiable for the go tool.

If something worked in glide 0.8 it was a fluke really.

Being held the GOPATH this way is a common compliant. We won't likely see a change before Go 2.x.

All 7 comments

@DavidJFelix is your root project properly in the GOPATH? You need to have something like GOPATH/src/path/to/root/project/vendor/github.com.... The go toolchain expects the root project to be in the GOPATH and specifically looks for the src directory.

I've been using glide per the usage section since go 1.5 successfully.

Here is exactly what I'm doing. You can repeat the results with docker

It's not clear what I'm doing wrong, since it used to work in 1.5

Should it be like this? GOPATH must not be vendor directory

RUN glide install

RUN GOPATH=/opt/evolution-master go build

I've tried that too. Nothing but moving vendor into vendor/src helps.

  • rename gosrc => src
  • GOPATH
  • in src, run glide install

But I recommend you set up like this:

GOPATH = /a/dir/

the checkout your repo to /a/dir/src/github.com/hatchery/evolution
in the checked-out directory, you put all contents of your current gosrc dir.

bootstrap/
Dockerfile
evolution-master.go
glide.lock
glide.yaml
LICENSE
README.md

@DavidJFelix thanks for sharing your Dockerfile. I see what's going on.

The GOPATH cannot be a vendor/ directory. This is hard coded into Go. You need something like...

WORKDIR /go/src/app

COPY ./gosrc /go/src/app
RUN glide install
RUN go build

The GOPATH here is /go. The GOPATH is required to have a directory inside named src where your source lives. The vendor/ directory is inside your source. This is non-negotiable for the go tool.

If something worked in glide 0.8 it was a fluke really.

Being held the GOPATH this way is a common compliant. We won't likely see a change before Go 2.x.

@mattfarina that seems to work, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marioluan picture marioluan  路  3Comments

ikouchiha47 picture ikouchiha47  路  6Comments

mh-cbon picture mh-cbon  路  3Comments

treeder picture treeder  路  4Comments

james-lawrence picture james-lawrence  路  5Comments