Skip to content

Use replace directives in go.mod in development only #41546

@ORESoftware

Description

@ORESoftware

Problem

My go.mod file has:

replace github.com/channelmeter/send-to-rollbar-via-stdin => ../send-to-rollbar-via-stdin

this replace directive works in dev but not in prod. How can I ignore certain replace directives when running go install in prod? I want the replace directive to be ignored.

The error shows up as follows:


Step 27/43 : RUN go install -v  2>&1
 ---> Running in 1d1717578978
go: github.com/channelmeter/send-to-rollbar-via-stdin@v0.0.0-20200922010219-c39f088cd56d: parsing ../send-to-rollbar-via-stdin/go.mod: open /go/src/github.com/channelmeter/send-to-rollbar-via-stdin/go.mod: no such file or directory
The command '/bin/sh -c go install -v  2>&1' returned a non-zero code: 1

What version of Go are you using (go version)?

go version go1.14.4 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Ubuntu Linux 64 bit

go env Output

AR="ar"
CC="gcc"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_ENABLED="1"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
CXX="g++"
GCCGO="gccgo"
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/alex/.cache/go-build"
GOENV="/home/alex/.config/go/env"
GOEXE=""
GOFLAGS=""
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build016167139=/tmp/go-build -gno-record-gcc-switches"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMOD="/home/alex/go/src/github.com/channelmeter/cp-go-api/go.mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/alex/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/home/alex/.local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/home/alex/.local/go/pkg/tool/linux_amd64"
PKG_CONFIG="pkg-config"

What did you do?

I ran go install in prod, which breaks since prod fs in a docker container is not like my local fs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions