bazelbuild/rules_go

Build is broken: buildifier renamed?

jayconrod opened this issue · 8 comments

github.com/bazelbuild/buildifier was renamed to github.com/bazelbuild/buildtools. This breaks our build with errors like this:

ERROR: /usr/local/google/home/jayconrod/Code/rules_go/BUILD:7:1: no such package '@com_github_golang_protobuf//ptypes/struct': no such package '@io_bazel_rules_go_repository_tools//': Traceback (most recent call last):
	File "/usr/local/google/home/jayconrod/Code/rules_go/go/private/go_repositories.bzl", line 91
		_fetch_repository_tools_deps(ctx, goroot, gopath)
	File "/usr/local/google/home/jayconrod/Code/rules_go/go/private/go_repositories.bzl", line 60, in _fetch_repository_tools_deps
		ctx.download_and_extract("%s/archive/%s.zip" % (dep.repo,...), <4 more arguments>)
java.io.IOException: Prefix buildifier-81c36a8418cb803d381335c95f8bb419ad1efa27 was given, but not found in the zip and referenced by '//:go_google_protobuf'.
ERROR: Analysis of target '//examples/proto/gostyle:go_default_library' failed; build aborted.
lizan commented

This breaks our builds in https://github.com/istio too.

@damienmg renamed it with the understanding that github would forward requests to the old repo

I'm testing a fix for this.

It looks like the zip we're downloading has the new name of the repository, which is different than we would expect, based on the URL. We ask Bazel to strip off a prefix from the zip that includes the name, and it fails to do so.

rtsai commented

Our project is also affected by this (we have a "buildifier_test" that runs buildifier against the BUILD file, that depends on buildifier).

Our workaround is to patch our project WORKSPACE (the bits merged in from the buildifier WORKSPACE) - project is currently using bazel 0.4.3

 http_archive(
     name = "io_bazel_rules_go",
-    sha256 = "890e055a9956daa85287ed309e8efaa9d5336b2bc5a71ad3676c220c99015a9d",
-    strip_prefix = "rules_go-0.3.2",
-    url = "https://github.com/bazelbuild/rules_go/archive/0.3.2.tar.gz",
+    sha256 = "77b9682e3734c34f3bc2971f65f9448307e9cd60be3a71aafab7ab1f67342c96",
+    strip_prefix = "rules_go-2d9f328a9723baf2d037ba9db28d9d0e30683938",
+    url = "https://github.com/bazelbuild/rules_go/archive/2d9f328a9723baf2d037ba9db28d9d0e30683938.tar.gz",
 )

That addresses fetching dependencies, but then building buildifier fails:

bazel build @com_github_bazelbuild_buildifier//buildifier
ERROR: .../5c346b5e4b6390e1d6c311b5361d6719/external/org_golang_x_tools/cmd/goyacc/BUILD:12:1: in go_binary rule @org_golang_x_tools//cmd/goyacc:goyacc: 
Traceback (most recent call last):
        File ".../5c346b5e4b6390e1d6c311b5361d6719/external/org_golang_x_tools/cmd/goyacc/BUILD", line 12
                go_binary(name = 'goyacc')
        File ".../5c346b5e4b6390e1d6c311b5361d6719/external/io_bazel_rules_go/go/def.bzl", line 565, in go_binary_impl
                go_library_impl(ctx)
        File ".../5c346b5e4b6390e1d6c311b5361d6719/external/io_bazel_rules_go/go/def.bzl", line 372, in go_library_impl
                runfiles.merge(d)
Type runfiles has no function merge(runfiles).
ERROR: Analysis of target '@com_github_bazelbuild_buildifier//buildifier:buildifier' failed; build aborted.

This failure is addressed by upgrading to bazel 0.4.5

Now that the buildifier repo contains {buildifier, buildozer, unused_deps} we decided to rename it to buildtools, and thought that github's auto-redirect of the old url to the new was sufficient.
However, apparently bazel's http_archive.strip_prefix throws a wrench in this.

rules_go is now working at HEAD, but broken before the commit. Not sure what the best way to proceed is.

I'm working on cherry-picking #362 and #319 (which is needed for separate import paths and repo URLs) to old releases. I'll tag point releases once that's ready. For people using Bazel 0.3.2 and Go 1.7, upgrading to master may be a pretty big inconvenience.

cc @jmhodges @junghoahnsc

0.4.2 and 0.3.4 releases are now available. This should fix the issue for people using older versions of these rules. 0.3.4 works with Bazel 0.3.2.

Thanks! 0.4.2 works for me.