Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: "error loading module requirements" from 'go mod download' #29213

Closed
TPTan96 opened this issue Dec 13, 2018 · 7 comments
Closed

cmd/go: "error loading module requirements" from 'go mod download' #29213

TPTan96 opened this issue Dec 13, 2018 · 7 comments

Comments

@TPTan96
Copy link

@TPTan96 TPTan96 commented Dec 13, 2018

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

$ go version
go version go1.11.2 windows/amd64

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

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\tptan\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\tptan\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\tptan\go\src\API\API\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64

What did you do?

Create an image docker

What did you expect to see?

an image

What did you see instead?

Step 6/10 : RUN go mod download
---> Running in 414efa3e565e
go: finding github.com/gorilla/mux v1.6.2
go: github.com/gorilla/mux@v1.6.2: unknown revision v1.6.2
go: error loading module requirements
The command '/bin/sh -c go mod download' returned a non-zero code: 1

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Dec 13, 2018

Please mention the exact steps so that we can reproduce this at our end.

What is the Dockerfile ? What is the repo ? Is there a go.mod ?

This is what I get -

$go mod init github.com/agnivade/mux
$go get github.com/gorilla/mux@v1.6.2
go: finding github.com/gorilla/mux v1.6.2
go: downloading github.com/gorilla/mux v1.6.2
$cat go.mod 
module github.com/agnivade/mux

require github.com/gorilla/mux v1.6.2 // indirect
@bcmills bcmills added this to the Go1.13 milestone Dec 14, 2018
@bcmills bcmills changed the title I used "RUN go mod download" but go: error loading module requirements cmd/go: "error loading module requirements" from 'go mod download' Dec 14, 2018
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jan 14, 2019

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Jan 14, 2019
@varuntechie

This comment has been minimized.

Copy link

@varuntechie varuntechie commented May 6, 2019

Facing the same error
" go clean -modcache
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/go-sql-driver/mysql v1.4.1
go: finding github.com/go-goracle/goracle v2.1.14+incompatible
go: github.com/go-goracle/goracle@v2.1.14+incompatible: unknown revision v2.1.14
go: github.com/go-sql-driver/mysql@v1.4.1: unknown revision v1.4.1
go: github.com/pkg/errors@v0.8.1: unknown revision v0.8.1
go: finding gopkg.in/goracle.v2 v2.13.1
go: gopkg.in/goracle.v2@v2.13.1: unknown revision v2.13.1
go: error loading module requirement"

@joshmsamuels

This comment has been minimized.

Copy link

@joshmsamuels joshmsamuels commented Jun 24, 2019

I am also encountering this problem.

@alwinmarkcf

This comment has been minimized.

Copy link

@alwinmarkcf alwinmarkcf commented Jul 18, 2019

Some more information would be awesome like:

Could not find module xy because of conflict:
mod ab: xy revision 1.2.0
mod lm: xy revision ^2.0.0

This message is just not useful

@Integralist

This comment has been minimized.

Copy link

@Integralist Integralist commented Sep 19, 2019

Yup I'm also getting this and it's unclear why...

# =============================================================================
# build stage
#
# install golang dependencies & build binaries
# =============================================================================
FROM golang:1.12 AS build

# install golint for running rig tests
RUN go get golang.org/x/lint/golint

# set initial working directory
WORKDIR /app

# use go modules to install dependencies
COPY go.mod ./
COPY go.sum ./
RUN go mod download

# copy over the rest of our files
COPY internal ./internal
COPY . ./

# compile our application
RUN go build -ldflags="-s -w" -o /bin/app ./cmd/app

# =============================================================================
# application stage
#
# copy binary from build stage
# =============================================================================
FROM debian:stable-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY scripts/test /app/scripts/test
COPY static/ /app/static
COPY --from=build /bin/app /bin/
CMD ["/bin/app"]
@Integralist

This comment has been minimized.

Copy link

@Integralist Integralist commented Sep 19, 2019

Ah, I cracked it.

So ./internal contained not only my application's own code but a symlink to my employer's organization wide packages (lib/**). These are then remapped inside of go.mod like so...

module github.com/foo/bar

go 1.12

require (
	foo/metrics v0.0.0
	foo/settings v0.0.0
	github.com/google/uuid v1.1.1
	github.com/sirupsen/logrus v1.4.1
)

replace (
	foo/metrics => ./internal/lib/metrics
	foo/settings => ./internal/lib/settings
)

I simply had to move that symlink to a ./vendor directory, then update the go.mod to point to that instead, and change the Dockerfile like so...

COPY vendor ./vendor
COPY go.mod ./
COPY go.sum ./
RUN go mod download
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.