compile: set GOPATH earlier for modules #406
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #396 the explicit
-mod=vendor
was removed from thego list
command used to find mainpackages 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 downloadedmodules 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.