From f63984bb33d4c6807a7effb4df45cf4b2a1ca431 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Tue, 16 Jul 2019 13:54:09 +0200 Subject: [PATCH 1/2] scripts: fail explicitly in updatedep.sh when gopath.proto exists I had been dealing with these intermittent failures for a while and finally figured out why. The real solution is making genproto.sh less ugly but that won't happen for a while. --- scripts/updatedep.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/updatedep.sh b/scripts/updatedep.sh index 22e37dc9b..c952ee875 100755 --- a/scripts/updatedep.sh +++ b/scripts/updatedep.sh @@ -6,6 +6,13 @@ if ! [[ "$0" =~ scripts/updatedep.sh ]]; then exit 255 fi +if [ -d "gopath.proto" ]; then + # gopath.proto is created by genproto.sh and it thoroughly messes + # with go mod. + echo "Remove gopath.proto before running this script" + exit 255 +fi + if [[ $(go version) != "go version go1.12"* ]]; then echo "expect Go 1.12+, got:" "$(go version)" exit 255 From 14625b847c3127254f56658b2e047b7db2b94ee9 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Tue, 16 Jul 2019 14:00:36 +0200 Subject: [PATCH 2/2] scripts: have genproto.sh clean up after itself We don't want it to leave gopath.proto around for reasons detailed in the previous commit (messing up vgo). --- scripts/genproto.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/genproto.sh b/scripts/genproto.sh index 99b57ba53..1dcdd9927 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -38,7 +38,14 @@ SCHWAG_ROOT="${GOPATH}/src/github.com/hexfusion/schwag" GOGOPROTO_PATH="${GOGOPROTO_ROOT}:${GOGOPROTO_ROOT}/protobuf" GRPC_GATEWAY_ROOT="${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway" -rm -f "${ETCD_ROOT}" +function cleanup { + # Remove the whole fake GOPATH which can really confuse go mod. + rm -rf "${PWD}/gopath.proto" +} + +cleanup +trap cleanup EXIT + mkdir -p "${ETCD_IO_ROOT}" ln -s "${PWD}" "${ETCD_ROOT}"