Skip to content

cmd/go: non-top-level packages ending in "/vendor" are omitted from module zip files #37397

Closed

Description

@bep

The following program fails in both go1.14rc1 and go1.13.7 darwin/amd64.

package main

import (
	"fmt"

	"github.com/bep/testmodlib"
	"github.com/bep/testmodlib/somepackage"
	"github.com/bep/testmodlib/somepackage/vendor"
	"github.com/bep/testmodlib/somepackage/vendors"
)

func main() {
	fmt.Println(testmodlib.Hello())
	fmt.Println(somepackage.Hello())
	fmt.Println(vendor.Hello())
	fmt.Println(vendors.Hello())
}

Fails with:

build github.com/bep/temp: cannot load github.com/bep/testmodlib/somepackage/vendor: module github.com/bep/testmodlib@latest found (v1.0.1), but does not contain package github.com/bep/testmodlib/somepackage/vendor

If I add a replace directive for that module:

replace github.com/bep/testmodlib => /Users/bep/dev/go/bep/testmodlib

It compiles/runs fine:

testmodlib
somepackage
vendor package
vendors package

I understand that the vendor top level folder in a module has a special meaning, but according to https://golang.org/ref/spec#Packages that package name should be fine -- and just deleting it sounds rather harsh.

I assume this is related to #31562 -- I have not read that one in detail, but I don't see how the conclusion can be correct.

  • github.com/bep/testmodlib/somepackage/vendor seem to be a valid package with a replace, and I assume that the compiler works as expected here.
  • Also, a module may contain non-Go folders (test resources etc. to make the test pass).

Activity

  1. gopherbot commented on Feb 24, 2020

    @gopherbot
    Contributor

    Change https://golang.org/cl/220640 mentions this issue: cmd/go/internal/modfetch: delete unused isVendoredPackage function

  2. bcmills commented on Feb 24, 2020

    @bcmills
    Contributor

    I assume this is related to #31562 -- I have not read that one in detail, but I don't see how the conclusion can be correct.

    You are correct: this is closely related. https://play.golang.org/p/zCP7U8cKAGc

  3. added this to the Unplanned milestone on Feb 24, 2020
  4. bcmills commented on Feb 24, 2020

    @bcmills
    Contributor

    CC @jayconrod @matloob, @FiloSottile FYI.

    (I don't think we can plausibly fix this without invalidating checksums, though.)

  5. gopherbot commented on Feb 24, 2020

    @gopherbot
    Contributor

    Change https://golang.org/cl/220657 mentions this issue: zip: document isVendoredPackage false-positives

  6. changed the title [-]modules: github.com/bep/testmodlib/somepackage/vendor fails[/-] [+]cmd/go: packages named "vendor" are erroneously omitted from module zip files[/+] on Feb 24, 2020
  7. changed the title [-]cmd/go: packages named "vendor" are erroneously omitted from module zip files[/-] [+]cmd/go: non-top-level packages named "vendor" are erroneously omitted from module zip files[/+] on Feb 24, 2020
  8. changed the title [-]cmd/go: non-top-level packages named "vendor" are erroneously omitted from module zip files[/-] [+]cmd/go: non-top-level packages ending in "/vendor" are omitted from module zip files[/+] on Feb 24, 2020
  9. FiloSottile commented on Feb 24, 2020

    @FiloSottile
    Contributor

    I suppose we could gate this sort of changes on the go.mod version?

  10. jayconrod commented on Feb 25, 2020

    @jayconrod
    Contributor

    @FiloSottile Unfortunately not. Old versions of cmd/go should still work with go.mod files that declare newer versions. So different versions of Go would produce different sums.

  11. bcmills commented on Feb 25, 2020

    @bcmills
    Contributor

    That proposal is #30369, but it seems unlikely to be accepted.

  12. 9 remaining items

  13. modified the milestones: Unplanned, Go1.24 on Oct 9, 2024
  14. self-assigned this
    on Oct 9, 2024
  15. gopherbot commented on Oct 9, 2024

    @gopherbot
    Contributor

    Change https://go.dev/cl/619175 mentions this issue: x/mod: fix handling of vendored packages with '/vendor' in non-top-level paths

  16. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    and removed
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Oct 10, 2024
  17. added a commit that references this issue on Oct 13, 2024
    c8a7319
  18. gucio321 commented on Feb 14, 2025

    @gucio321
    Contributor

    Does it work for anyone after 1.24 release? Because it seems it doesn't for me unfortunately. I've upgraded my module's require to 1.24 so it should work, shouldn't it?

  19. locked and limited conversation to collaborators on Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions