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

Failed to compile testmain package when running example even set GO111MODULE=off #405

Closed
dluong777 opened this issue Jul 9, 2021 · 6 comments

Comments

@dluong777
Copy link

Please answer these questions before submitting a bug report.

What version of godog are you using?

> godog version
Godog version is: v0.11.0

What version of Go are you using?

> go version
go version go1.16.3 darwin/amd64

What did you do?

If possible, provide a recipe for reproducing the error.

I was trying to run the example from README.MD. It ran successfully at first. The code was within the Go workspace ($HOME/go/src). I pushed the code to GitHub, then trying to run other examples with godog

What did you expect to see?

Other Godogs examples will be run successfully

What did you see instead?

failed to compile testmain package: exit status 2 - output: /var/folders/zs/ctwcqjz12sbfgmhmw2w213cw0000gq/T/go-build1525418886/b001/_testmain.go:5:2: can't find import: "godog-cucumber-playaround"

Note : the godog-cucumber-playaround is the public Git repo, which I pushed my code here.

Additional context

After referred to https://github.com/cucumber/godog#examples to use GO111MODULE=off, I still cannot get it works properly

> GO111MODULE=off godog

The CLI showed like this

failed to compile tested package: /Users/admin/go/src/godog-cucumber-playaround, reason: exit status 1, output: WORK=/var/folders/zs/ctwcqjz12sbfgmhmw2w213cw0000gq/T/go-build2850980379

# godog-cucumber-playaround
godogs_test.go:5:2: cannot find package "github.com/cucumber/godog" in any of:
	/usr/local/Cellar/go/1.16.3/libexec/src/github.com/cucumber/godog (from $GOROOT)
	/Users/admin/go/src/github.com/cucumber/godog (from $GOPATH)
FAIL	godog-cucumber-playaround [setup failed]

The solution works for me

Move the project out of $GOPATH and run godog again (without using GO111MODULE=off )

@inluxc
Copy link

inluxc commented Jul 12, 2021

Godog is a Go Module, you can't use it without GO111MODULE=on.

@dluong777
Copy link
Author

Godog is a Go Module, you can't use it without GO111MODULE=on.

Note that if you want to execute any of the examples and have the Git repository checked out in the $GOPATH, you need to use: GO111MODULE=off. Issue for reference.

This is what I found in the Godog documentation.

@cakoolen
Copy link

When I try to build with go modules turned off, I get the following error message:

could not build binary at: testharness failed to tidy modules in tested package: [some source folder], reason: exit status 1, output: go: modules disabled by GO111MODULE=off; see 'go help modules'

I think this is related to internal/builder/builder.go#L130 where go mod tidy is called without respecting the GO111MODULE flag

Even though we use a go module, we have vendored all our source code using go mod vendor to make it easier to build our code within a docker image. If we need to build with modules enabled, running go mod tidy would fail as well since it cannot reach half the sources mentioned in the go.mod file from within the docker container building the sources.

It would be helpful if calling go mod tidy depends on the GO111MODULE flag such that we can still build within a Dockerfile

@vearutop
Copy link
Member

vearutop commented Oct 14, 2021

@cakoolen please try installing godog from a branch with go install github.com/cucumber/godog@non-module and then using it in your context. If it works ok we can merge #436.

@cakoolen
Copy link

@vearutop that was fast! Sorry it took me some time to validate your changes but for me these work really nice. It would be great to see them in the main release.

@vearutop
Copy link
Member

Fixed in v0.12.2.

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

5 participants