cloudfoundry / go-buildpack

Cloud Foundry buildpack for the Go Language
http://docs.cloudfoundry.org/buildpacks/
Apache License 2.0
82 stars 119 forks source link

Go Buildpack fails to locate package in sub directory #70

Closed lunim closed 5 years ago

lunim commented 5 years ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?

"api_version": "2.126.0", "osbapi_version": "2.14", cf version 6.38.0+7ddf0aadd.2018-08-07

What version of the buildpack you are using?

Go Buildpack version 1.8.29

If you were attempting to accomplish a task, what was it you were attempting to do?

Push a go module with a sub-package

What did you expect to happen?

Successful compile and run

What was the actual behavior?

main.go:5:2: cannot find package "go-tick/util" in any of: /tmp/gobuildpack.gopath149924292/.go/src/go-tick/main/vendor/go-tick/util (vendor tree)

I created a simple go module (1.11.2) using go mod init go-tick. I created a sub directory called 'util' which contains a common.go file using the package name "common". I import using the statement import "go-tick/util" which works fine locally. When pushing to cloud foundry, it neither fetches third party imports or resolves my local package like the go 1.11 build command does.

cf-gitbot commented 5 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/162426590

The labels on this github issue will be updated when the story is started.

djoyahoy commented 5 years ago

We are unable to reproduce this issue. Can you provide a sample application that displays this behavior?

lunim commented 5 years ago

Here is a sample app: https://github.com/lunim/go-tick

And here is the log output from the deploy:

Getting app info...
Creating app with these attributes...
+ name:         go-tick
  path:         C:\Users\<user>\Documents\Code\go-tick
  buildpacks:
+   https://github.com/cloudfoundry/go-buildpack.git#v1.8.29
+ disk quota:   256M
+ instances:    1
+ memory:       256M
  env:
+   GOPACKAGENAME
+   GOVERSION
  routes:
+   go-tick.apps1-<site-url>

Creating app go-tick...
Mapping routes...
Comparing local files to remote cache...
Packaging files to upload...
Uploading files...
 825 B / 825 B [===========================================================================================] 100.00% 1s

Waiting for API to complete processing files...

Staging app and tracing logs...
   Cell f197f720-95bd-4a76-8752-776d4908411e creating container for instance 89f3ac9b-030b-4c4c-8bf0-5650046ca8ef
   Cell f197f720-95bd-4a76-8752-776d4908411e successfully created container for instance 89f3ac9b-030b-4c4c-8bf0-5650046ca8ef
   Downloading app package...
   Downloaded app package (825B)
   -----> Download go 1.9.1
   -----> Running go build supply
   -----> Go Buildpack version 1.8.29
   -----> Installing godep 80
          Download [https://buildpacks.cloudfoundry.org/dependencies/godep/godep-v80-linux-x64-cflinuxfs3-b60ac947.tgz]
   -----> Installing glide 0.13.2
          Download [https://buildpacks.cloudfoundry.org/dependencies/glide/glide-v0.13.2-linux-x64-cflinuxfs3-b50997e2.tgz]
   -----> Installing dep 0.5.0
          Download [https://buildpacks.cloudfoundry.org/dependencies/dep/dep-v0.5.0-linux-x64-cflinuxfs3-f9b0e8ec.tgz]
   -----> Installing go 1.11.2
          Download [https://buildpacks.cloudfoundry.org/dependencies/go/go1.11.2.linux-amd64-cflinuxfs3-ea36bdde.tar.gz]
   -----> Running go build finalize
          **WARNING** Installing package '.' (default)
   -----> Running: go install -tags cloudfoundry -buildmode pie .
   tick.go:5:5: cannot find package "go-tick/util" in any of:
        /tmp/contents143417830/deps/0/go1.11.2/go/src/go-tick/util (from $GOROOT)
        /tmp/gobuildpack.gopath325921557/.go/src/go-tick/util (from $GOPATH)
          **ERROR** Unable to compile application: exit status 1
   Failed to compile droplet: Failed to run finalize script: exit status 12
   Exit status 223
   Cell f197f720-95bd-4a76-8752-776d4908411e stopping instance 89f3ac9b-030b-4c4c-8bf0-5650046ca8ef
   Cell f197f720-95bd-4a76-8752-776d4908411e destroying container for instance 89f3ac9b-030b-4c4c-8bf0-5650046ca8ef
Error staging application: App staging failed in the buildpack compile phase
FAILED
kardolus commented 5 years ago

Hi @lunim, do you have GO111MODULE set to "on"? - This variable is required for the current go_buildpack in order to use go modules (fix is on the way, see https://github.com/cloudfoundry/go-buildpack/commit/0dbae340c730b394d6f45fc1e6f93341ca69ee3d)

lunim commented 5 years ago

Thank you for the information, setting GO111MODULE: "on" in the manifest has resolved the deploy issue.