Skip to content

go_path fails with "symlink <dst> <src>: file exists" when srcs include genrules #1439

@guoshimin

Description

@guoshimin

Can be reproduced with the following rules

genrule(
    name = "dummy",
    srcs = ["dummy.txt"],
    outs = ["dummy.go"],
    cmd = "cp $< $@",
)

go_library(
    name = "lib",
    srcs = [":dummy"],
    importpath = "dummy",
)

go_path(
    name = "foobar",
    deps = [
        ":lib",
    ],
    mode = "link",
)
// dummy.txt
package dummy
$ bazel build //go:foobar
INFO: Analysed target //go:foobar (0 packages loaded).
INFO: Found 1 target...
ERROR: /home/shimin/<redacted>/go/BUILD.bazel:43:1: GoPath go/foobar/src/dummy/dummy.go failed (Exit 1)
symlink ../../../../../genfiles/go/dummy.go bazel-out/k8-fastbuild/bin/go/foobar/src/dummy/dummy.go: file exists
Target //go:foobar failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.331s, Critical Path: 0.06s
FAILED: Build did NOT complete successfully

Using rules_go at 27b444a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions