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

compile: set GOPATH earlier for modules #406

Merged
merged 1 commit into from
Apr 24, 2020
Merged

Conversation

danp
Copy link
Contributor

@danp danp commented Apr 23, 2020

In #396 the explicit
-mod=vendor was removed from the go list command used to find main
packages to install. This enabled it to fetch modules as necessary for
listing if vendoring was not being used. When modules are fetched,
they are fetched into $GOPATH/pkg/mod. If GOPATH is not set, it
defaults to $HOME/go.

In build mode, at least Heroku runs compile with a build directory
that is not the same as $HOME. In test mode, however, at least Heroku
CI runs test-compile with a build directory that is equal to
$HOME.

When this initial go list was being run, GOPATH was not yet set,
which in test mode downloaded modules to $HOME/go. Later, once go test ./... or similar was run in $HOME, the source of the downloaded
modules was being considered. This caused errors such as:

go: directory go/pkg/mod/github.com/gorilla/mux@v1.6.2 outside available modules

To fix this, set GOPATH for modules earlier, before go list is run.

To get better test fidelity, run testpack tests with HOME set to the
temporary build directory.

In #396 the explicit
`-mod=vendor` was removed from the `go list` command used to find main
packages to install. This enabled it to fetch modules as necessary for
listing if vendoring was not being used. When modules are fetched,
they are fetched into $GOPATH/pkg/mod. If GOPATH is not set, it
defaults to $HOME/go.

In build mode, at least Heroku runs compile with a build directory
that is not the same as $HOME. In test mode, however, at least Heroku
CI runs test-compile with a build directory that is equal to
$HOME.

When this initial `go list` was being run, GOPATH was not yet set,
which in test mode downloaded modules to $HOME/go. Later, once `go
test ./...` or similar was run in $HOME, the source of the downloaded
modules was being considered. This caused errors such as:

go: directory go/pkg/mod/github.com/gorilla/mux@v1.6.2 outside available modules

To fix this, set GOPATH for modules earlier, before `go list` is run.

To get better test fidelity, run testpack tests with HOME set to the
temporary build directory.
@danp danp requested a review from a team as a code owner April 23, 2020 16:53
@edmorley edmorley merged commit d25d76a into master Apr 24, 2020
@edmorley edmorley deleted the modules-earlier-gopath branch April 24, 2020 13:24
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

Successfully merging this pull request may close these issues.

3 participants