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

Install Mockery in docker #364

Open
ashkank83 opened this issue Feb 12, 2021 · 4 comments
Open

Install Mockery in docker #364

ashkank83 opened this issue Feb 12, 2021 · 4 comments

Comments

@ashkank83
Copy link

Trying to install Mockery as one of the steps of building my docker image (dev container) I have started getting the following error:

 > [6/7] RUN go get github.com/vektra/mockery:
#9 24.62 cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:
#9 24.62 	/usr/local/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOROOT)
#9 24.62 	/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOPATH)

I have to say this was working until recently.
Below is my Docker file (very much standard VS Code Go docker container)

# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/go/.devcontainer/base.Dockerfile

# [Choice] Go version: 1, 1.15, 1.14
ARG VARIANT="1"
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}

# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# install protobuf for gRPC
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
    && apt-get -y install --no-install-recommends protobuf-compiler \
    && apt-get -y install --no-install-recommends clang-format 
RUN go get -u google.golang.org/grpc 
RUN go get -u github.com/golang/protobuf/protoc-gen-go 
RUN go get github.com/vektra/mockery && go get -u github.com/vektra/mockery/v2/.../

@SophieDeBenedetto
Copy link

Signal bumping this--having the same issue.

@LandonTClipp
Copy link
Contributor

Can you pinpoint this to a specific version of mockery where this bug was introduced?

@tte
Copy link

tte commented Feb 26, 2021

Bumped into the same issue for mockery v1

FROM golang:1.13-alpine3.12
RUN go get -u github.com/vektra/mockery/...

package github.com/vektra/mockery
	imports github.com/hashicorp/hcl/hcl/printer: cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:
	/usr/local/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOROOT)
	/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOPATH)

Solved by adding GO111MODULE=on env to Dockerfile

@ashkank83
Copy link
Author

@LandonTClipp It seems to be happening for the following command:

RUN go get github.com/vektra/mockery && go get -u github.com/vektra/mockery/v2/.../

Which I assume is trying to get the latest version of mockery available. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants