Skip to content
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

new_go_repository does not work with golang.org/x/text on macOS #144

Closed
swsnider opened this issue Oct 13, 2016 · 12 comments
Closed

new_go_repository does not work with golang.org/x/text on macOS #144

swsnider opened this issue Oct 13, 2016 · 12 comments
Labels

Comments

@swsnider
Copy link
Contributor

Since golang.org/x/text/collate/build is a package, and macOS by default has a case-insensitive (but case-respecting) filesystem, I cannot use new_go_repository with that package.

Before new_go_repository existed, I was overlaying my own BUILD files using new_git_repository, which did not have this issue because I used on per repository, instead of one per package.

Apparently it is in some cases possible to convert your filesystem losslessly to case-sensitive using iPartition, but that doesn't work if you're encrypting your hard drive.

Can the new_go_repository rules be changed to use this same approach? Or is there a technical reason why that wouldn't work?

This came up because I'm actually trying to depend on an entirely different package, afero, using the following WORKSPACE

git_repository(
    name = "io_bazel_rules_go",
    remote = "https://github.com/bazelbuild/rules_go.git",
    tag = "0.2.0",
)
load("@io_bazel_rules_go//go:def.bzl", "go_repositories", "new_go_repository")
go_repositories()

new_go_repository(
  name = "org_golang_x_text",
  importpath = "github.com/golang/text",
  commit = "d69c40b4be55797923cec7457fac7a244d91a9b6",
)

new_go_repository(
  name = "com_github_pkg_sftp",
  importpath = "github.com/pkg/sftp",
  commit = "a71e8f580e3b622ebff585309160b1cc549ef4d2",
)

new_go_repository(
  name = "com_github_spf13_afero",
  importpath = "github.com/spf13/afero",
  commit = "52e4a6cfac46163658bd4f123c49b6ee7dc75f78",
)

The actual error is:

$ bazel build //...:all
ERROR: /private/var/tmp/_bazel_swsnider/d980a28a08d1d45d19e13e085f723430/external/com_github_spf13_afero/BUILD:5:1: no such package '@org_golang_x_text//unicode/norm': failed to generate BUILD files for github.com/golang/text: 2016/10/12 23:42:24 open /private/var/tmp/_bazel_swsnider/d980a28a08d1d45d19e13e085f723430/external/org_golang_x_text/collate/BUILD: is a directory
 and referenced by '@com_github_spf13_afero//:go_default_library'.
ERROR: Analysis of target '//compiler/cmd/pp:pp' failed; build aborted.
INFO: Elapsed time: 33.302s
@yugui
Copy link
Contributor

yugui commented Oct 13, 2016

Thank you for reporting the issue.

Can the new_go_repository rules be changed to use this same approach? Or is there a technical reason why that wouldn't work?

No. Technically it is possible to automatically generate a BUILD file like the one you wrote.

Actually I have a plan to add such a mode to Gazelle for packages vendored with "git submodule". c.f. #16 (comment).
But also this case of golang.org/x/text shows that new_go_repository rule sometimes needs this style of single BUILD file.

@swsnider
Would you mind tentatively using new_git_repository only for golang.org/x/text as a workaround?

@swsnider
Copy link
Contributor Author

I can try, but I was having issues getting my overlay build file to look right to the new rules. I'll see if I can infer the Chevy structure from the partial ones being generated.

@pmbethe09
Copy link
Contributor

There is an upcoming change to bazel where BUILD files are allowed to be
called 'BUILD.bazel' and then a directory named 'build' is fine.
My understanding is that CL is in flight and close to submission, so I
expect by the end of the month we could update new_go_repository+gazelle to
generate into 'BUILD.bazel' and then the problem goes away.
As such, I am inclined to do nothing for now since it is not long until we
can fix it.

On Thu, Oct 13, 2016 at 9:43 AM, Silas Snider [email protected]
wrote:

I can try, but I was having issues getting my overlay build file to look
right to the new rules. I'll see if I can infer the Chevy structure from
the partial ones being generated.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#144 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALF-0neBPBcpzK6jDApmQYMFzaPn_JMKks5qzjWDgaJpZM4KVi4t
.

@kerinin
Copy link
Contributor

kerinin commented Nov 8, 2016

Has there been any movement on this issue? I've tried creating a new_git_repository, but I'm not sure how to create BUILD files for sub-packages this way. Example:

X_TEXT_BUILD = """
load("@io_bazel_rules_go//go:def.bzl", "go_prefix", "go_library")
go_prefix("golang.org/x/text")
go_library(
    name = "go_default_library",
    srcs = glob(["*.go"]),
    visibility = ["//visibility:public"],
)
"""
new_git_repository(
    name = "org_golang_x_text",
    build_file_content = X_TEXT_BUILD,
    commit = "4440cd4f4c2ea31e1872e00de675a86d0c19006c",
    remote = "https://github.com/golang/text")

This fails to build with errors like no such package '@org_golang_x_text//transform': BUILD file not found on package path and referenced by '@org_golang_x_net//html/charset:go_default_library'

@pmbethe09
Copy link
Contributor

the change we need from bazel is under review, so it should only be another week or two until we can make the changes to gazelle.

I think you have to create a target for each directory
go_library(
name = "collate/build",
srcs = glob(["collate/build/_.go"], exclude=["__/__test.go"]),
visibility = ["//visibility:public"],
deps = [
":internal/colltab",
":language",
":unicode/norm",
],
)

And so forth for every library in there.

@kerinin
Copy link
Contributor

kerinin commented Dec 1, 2016

It looks like 0.4.1 allows 'BUILD.bazel' - is this still blocked?

@pmbethe09
Copy link
Contributor

pmbethe09 commented Dec 1, 2016 via email

@twpayne
Copy link
Contributor

twpayne commented Jan 10, 2017

This should be fixed by #228.

@jayconrod
Copy link
Contributor

This seems to be working now. I'm able to run bazel build @org_golang_x_text//... without error.

@jmhodges
Copy link
Contributor

This isn't working for me on bazel 0.4.5 and rules_go at 7cce22e.

ERROR: /private/var/tmp/_bazel_jmhodges/ee957dabdee1b1a9e1f2fe90369cf80f/external/org_golang_x_net/idna/BUILD:3:1: no such package '@org_golang_x_text//unicode/norm': failed to generate BUILD files for golang.org/x/text: 2017/04/16 03:26:33 open /private/var/tmp/_bazel_jmhodges/ee957dabdee1b1a9e1f2fe90369cf80f/external/org_golang_x_text/collate/BUILD: is a directory
 and referenced by '@org_golang_x_net//idna:go_default_library'.
ERROR: Analysis of target '//go/foobar:go_default_library' failed; build aborted.

@jmhodges
Copy link
Contributor

I had to add an explicit build_file_name = "BUILD.bazel to my org_golang_x_text new_go_respository call in order for this work.

This seems like something rules_go could be defaulting to for versions at 0.4.5 and later?

@jayconrod jayconrod reopened this Apr 17, 2017
@jayconrod
Copy link
Contributor

I'll double-check on this. It does seem like something we should be defaulting to.

jayconrod pushed a commit to jayconrod/rules_go that referenced this issue Apr 17, 2017
Generated BUILD files may conflict with other files or directories
named "build" on case insensitive file systems. "BUILD.bazel" is less
likely to conflict, and Bazel supports these files since 0.4.1.

The filename can still be overridden by specifying the build_file_name
attribute. This just changes the default.

Fixes bazel-contrib#144
jayconrod added a commit that referenced this issue Apr 17, 2017
Generated BUILD files may conflict with other files or directories
named "build" on case insensitive file systems. "BUILD.bazel" is less
likely to conflict, and Bazel supports these files since 0.4.1.

The filename can still be overridden by specifying the build_file_name
attribute. This just changes the default.

Fixes #144
groodt pushed a commit to groodt/rules_go that referenced this issue Mar 14, 2022
* run go generate for new stdlib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants