Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Inconsistant GOPATH during CI build #2268

Closed
juliancarrivick-ibm opened this issue Jul 21, 2016 · 3 comments
Closed

Inconsistant GOPATH during CI build #2268

juliancarrivick-ibm opened this issue Jul 21, 2016 · 3 comments

Comments

@juliancarrivick-ibm
Copy link
Contributor

Description

I've been trying to complete PR #2190 but during the build Travis (and Jenkins) fails to run the executable at $GOPATH/bin/chaincode_example02 inside the chaincode container (I'm running it manually to test when it is in developer mode) it cannot find the file. This seems to be because when the ccenv docker image is made $GOPATH=/opt/gopath but when the container runs in the context of Travis it is /home/travis/gopath.
To add to the confusion when injecting a go env call where it fails it says $GOPATH=/opt/gopath.
Additionally, GOPATH=/opt/gopath $GOPATH/bin/chaincode_example02 still calls /home/travis/gopath/bin/chaincode_example02!
I honestly have no idea what is going on here. Any help would be very much appreciated.

The docker compose file is:

vp0:
  extends:
    file: compose-defaults.yml
    service: vp
  environment:
    - CORE_PEER_ID=vp0
  command: sh -c "peer node start --peer-chaincodedev"

ccenv:
  image: hyperledger/fabric-ccenv
  environment:
    - CORE_CHAINCODE_ID_NAME=testCC
    - CORE_PEER_ADDRESS=vp0:30303
  command: bash -c "go env; GOBIN=/opt/gopath/bin go install github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 && echo $GOPATH && go env && /opt/gopath/bin/FAIL/chaincode_example02"
  links:
    - vp0

I've deliberately put an non existant path in the chaincode_example02 call so that it fails and I can collect the logs from Travis.
Also, adding the GOBIN=... before Go install allows me to explicitly do the call to the final executable in the last executed step, which works around the issue.

During running the docker container for the BDD tests the output of

go env; GOBIN=/opt/gopath/bin go install github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 && echo $GOPATH && go env && /opt/gopath/bin/FAIL/chaincode_example02

results in:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/gopath"
GORACE=""
GOROOT="/opt/go"
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
/home/travis/gopath
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/gopath"
GORACE=""
GOROOT="/opt/go"
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
bash: /opt/gopath/bin/FAIL/chaincode_example02: No such file or directory

I would expect that go install github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 && $GOPATH/bin/chaincode_example02
would be necessary to build and run the code.

Even though I have currently worked around the issue, I thought it should be tracked.

Describe How to Reproduce

Look at https://travis-ci.org/hyperledger/fabric/jobs/146273836 travis run.

@christo4ferris
Copy link
Contributor

@rameshthoomu would you please look at this? thanks

@rameshthoomu
Copy link
Contributor

rameshthoomu commented Jul 26, 2016

Working on this issue..

@juliancarrivick-ibm
Copy link
Contributor Author

Figured this out, it seems that docker-compose was doing its own substitution before the command got to the container. Hence the seemingly inconsistent values.

Changing go install github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 && $GOPATH/bin/chaincode_example02 to go install github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 && $$GOPATH/bin/chaincode_example02 (adding an extra dollar sign) escapes docker-compose's substitutions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants