Skip to content

resolve/gosource: remove files in GOMODCACHE from discovered inputs #639

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

Merged
merged 3 commits into from
Apr 25, 2025

Conversation

fho
Copy link
Collaborator

@fho fho commented Apr 20, 2025

This fixes that when the Gosource input resolver is used on a Go
application that uses non-vendored 3. party packages, baur fails with:

ERROR: [..] evaluating task status failed: Rel: can't make
$GOMODCACHE/[..] relative to /home/[...]

Imported 3. party packages that aren't vendored are stored by Go in the
GOMODCACHE directory.
When the Gosource resolver resolves a task to sources in the GOMODCACHE,
it replaces the path to the GOMODCACHE in the input file path with
'$GOMODCACHE'. This is done to always have the same reproducible input
files paths, independent of what the actual GOMODCACHE directory is.

The inputresolver afterwards tries to evaluate the repository relative
path of the input file containing the '$GOMODCACHE' which fails with the
error.
The real path to the input file is not known by the inputresolver, which
makes it difficult to track changes in the GOMODCACHE.

Instead of replacing the GOMODCACHE directory in paths, omit returning
files in the GOMODCACHE, same procedure as it is done for stdlib input files.

Instead a task can track and rely on the information in the go.mod or
go.sum files to track changes of 3. party libraries.
If the files in the GOMODCACHE of a downloaded 3. party packages are
modified manually, baur won't notice the change.

Fixes #637

Follow-up: #642

@fho fho self-assigned this Apr 20, 2025
@fho fho marked this pull request as ready for review April 20, 2025 10:05
fho added 3 commits April 20, 2025 12:05
Clarify some unclear code comments
This fixes that when the Gosource input resolver is used on a Go
application that uses non-vendored 3. party packages, baur fails with:

  ERROR: [..] evaluating task status failed: Rel: can't make
  $GOMODCACHE/[..] relative to /home/[...]

Imported 3. party packages that aren't vendored are stored by Go in the
GOMODCACHE directory.
When the Gosource resolver resolves a task to sources in the GOMODCACHE,
it replaces the path to the GOMODCACHE in the input file path with
'$GOMODCACHE'. This is done to always have the same reproducible input
files paths, independent of what the actual GOMODCACHE directory is.

The inputresolver afterwards tries to evaluate the repository relative
path of the input file containing the '$GOMODCACHE' which fails with the
error.
The real path to the input file is not known by the inputresolver, which
makes it difficult to track changes in the GOMODCACHE.

Instead of replacing the GOMODCACHE directory in paths, omit returning
files in the GOMODCACHE, same procedure as it is done for stdlib input files.

Instead a task can track and rely on the information in the go.mod or
go.sum files to track changes of 3. party libraries.
This has the disadvantage that if files in the GOMODCACHE are modified,
it won't be noticed by baur.
@fho fho force-pushed the gomodcache_rel_err branch from 4fa4065 to 6681f89 Compare April 20, 2025 10:06
@fho fho requested review from nocive and FranciscoKurpiel April 22, 2025 10:31
@fho fho merged commit 760a759 into main Apr 25, 2025
6 checks passed
@fho fho deleted the gomodcache_rel_err branch April 25, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Cannot run go targets
3 participants