Fail to build nginx with latest brotli with bazel #233

Closed
opened 2026-01-29 20:40:19 +00:00 by claunia · 10 comments
Owner

Originally created by @S8Cloud on GitHub (May 31, 2018).

I saw a repository that use bazel to build nginx (along with boringssl & brotli) at google git and I modified just 2 lines to use the latest brotli

  • File build
  • oringin version (begin at L620)
def nginx_repositories_brotli(bind):
    native.git_repository(
        name = "org_brotli",
        commit = "222564a95d9ab58865a096b8d9f7324ea5f2e03e",  # 2016-12-02
        remote = "https://github.com/google/brotli.git",
    )

    if bind:
        native.bind(
            name = "brotli_enc",
            actual = "@org_brotli//:brotlienc"
        )

        native.bind(
            name = "brotli_dec",
            actual = "@org_brotli//:brotlidec"
        )

def nginx_repositories_ngx_brotli(nginx):
    native.new_git_repository(
        name = "ngx_brotli",
        build_file_content = _NGX_BROTLI_BUILD_FILE.format(nginx = nginx),
        commit = "5ead1ada782b18c7b38a3c2798a40a334801c7b6",  # 2016-12-05
        remote = "https://nginx.googlesource.com/ngx_brotli",
    )

It works fine but when I changed it to

  • new version modified:
def nginx_repositories_brotli(bind):
    native.git_repository(
        name = "org_brotli",
        commit = "f9b8c02673c576a3e807edbf3a9328e9e7af6d7c",
        remote = "https://github.com/google/brotli.git",
    )
...
def nginx_repositories_ngx_brotli(nginx):
    native.new_git_repository(
        name = "ngx_brotli",
        build_file_content = _NGX_BROTLI_BUILD_FILE.format(nginx = nginx),
        commit = "37ab9b2933a0b756ba3447000b7f31d432ed8228",
        remote = "https://github.com/eustas/ngx_brotli.git",
    )

It comes with build error:

ERROR: /root/nginx-bazel/build.bzl:627:9: error loading package '@org_brotli//': Extension file not found. Unable to load package for '@io_bazel_rules_go//go:def.bzl': The repository could not be resolved and referenced by '//external:brotli_enc'
ERROR: Analysis of target '//:nginx' failed; build aborted: Loading failed                                 
INFO: Elapsed time: 4.632s                                                                                 
INFO: 0 processes.                                                                                         
FAILED: Build did NOT complete successfully (12 packages loaded)                                           
    currently loading: @org_brotli//

My system is Ubuntu 18.04 LTS with stable bazel.

Originally created by @S8Cloud on GitHub (May 31, 2018). I saw a repository that use bazel to build nginx (along with boringssl & brotli) at [google git](https://nginx.googlesource.com/nginx) and I modified just 2 lines to use the latest brotli * File [build](https://nginx.googlesource.com/nginx/+/master/build.bzl) * oringin version (begin at L620) ``` def nginx_repositories_brotli(bind): native.git_repository( name = "org_brotli", commit = "222564a95d9ab58865a096b8d9f7324ea5f2e03e", # 2016-12-02 remote = "https://github.com/google/brotli.git", ) if bind: native.bind( name = "brotli_enc", actual = "@org_brotli//:brotlienc" ) native.bind( name = "brotli_dec", actual = "@org_brotli//:brotlidec" ) def nginx_repositories_ngx_brotli(nginx): native.new_git_repository( name = "ngx_brotli", build_file_content = _NGX_BROTLI_BUILD_FILE.format(nginx = nginx), commit = "5ead1ada782b18c7b38a3c2798a40a334801c7b6", # 2016-12-05 remote = "https://nginx.googlesource.com/ngx_brotli", ) ``` It works fine but when I changed it to * new version modified: ``` def nginx_repositories_brotli(bind): native.git_repository( name = "org_brotli", commit = "f9b8c02673c576a3e807edbf3a9328e9e7af6d7c", remote = "https://github.com/google/brotli.git", ) ... def nginx_repositories_ngx_brotli(nginx): native.new_git_repository( name = "ngx_brotli", build_file_content = _NGX_BROTLI_BUILD_FILE.format(nginx = nginx), commit = "37ab9b2933a0b756ba3447000b7f31d432ed8228", remote = "https://github.com/eustas/ngx_brotli.git", ) ``` It comes with build error: ``` ERROR: /root/nginx-bazel/build.bzl:627:9: error loading package '@org_brotli//': Extension file not found. Unable to load package for '@io_bazel_rules_go//go:def.bzl': The repository could not be resolved and referenced by '//external:brotli_enc' ERROR: Analysis of target '//:nginx' failed; build aborted: Loading failed INFO: Elapsed time: 4.632s INFO: 0 processes. FAILED: Build did NOT complete successfully (12 packages loaded) currently loading: @org_brotli// ``` My system is Ubuntu 18.04 LTS with stable bazel.
Author
Owner

@eustas commented on GitHub (May 31, 2018):

Didn't know that there is Bazel build for nginx =)
Going to investigate soon.

@eustas commented on GitHub (May 31, 2018): Didn't know that there is Bazel build for nginx =) Going to investigate soon.
Author
Owner

@eustas commented on GitHub (May 31, 2018):

I have a simple explanation now: googlesource ngx_brotli differs from github ngx_brotli.
Going to add Bazel WORKSPACE / BUILD to eustas/ngx_brotli soon.
Would appreciate if you close this issue here and create it at eustas/ngx_brotli instead. Thanks!

@eustas commented on GitHub (May 31, 2018): I have a simple explanation now: googlesource ngx_brotli differs from github ngx_brotli. Going to add Bazel WORKSPACE / BUILD to eustas/ngx_brotli soon. Would appreciate if you close this issue here and create it at eustas/ngx_brotli instead. Thanks!
Author
Owner

@S8Cloud commented on GitHub (May 31, 2018):

Actually it can be built successfully with your eustas/ngx_brotli and old google/brotli github version as it is just the same as googlesource brotli.
So I think the problem may comes from newer version of google/brotli (github version).

@S8Cloud commented on GitHub (May 31, 2018): Actually it can be built successfully with your `eustas/ngx_brotli` and `old google/brotli` [github version](https://github.com/google/brotli/commit/222564a95d9ab58865a096b8d9f7324ea5f2e03e) as it is just the same as `googlesource brotli`. So I think the problem may comes from newer version of google/brotli (github version).
Author
Owner

@eustas commented on GitHub (May 31, 2018):

Hmm. Error says that there is problem with golang Bazel plugin. Going to try to update it to the latest version.

@eustas commented on GitHub (May 31, 2018): Hmm. Error says that there is problem with golang Bazel plugin. Going to try to update it to the latest version.
Author
Owner

@eustas commented on GitHub (May 31, 2018):

Updated golang/JS bazel plugins to latest stable (#676); not sure if this will help; going to try building nginx with newer brotli later.

@eustas commented on GitHub (May 31, 2018): Updated golang/JS bazel plugins to latest stable (#676); not sure if this will help; going to try building nginx with newer brotli later.
Author
Owner

@S8Cloud commented on GitHub (May 31, 2018):

Changed org_brotli into commit 29dc2cce9090d6c92c908116e11373bc7fdc8ad1

Starting local Bazel server and connecting to it...
................
ERROR: /root/nginx-bazel/BUILD:1432:1: error loading package '@org_brotli//': Extension file not found. Unable to load package for '@io_bazel_rules_go//go:def.bzl': The repository could not be resolved and referenced by '//:nginx-google-copyright'                                                                          
ERROR: Analysis of target '//:nginx-google.deb' failed; build aborted: error loading package '@org_brotli//': Extension file not found. Unable to load package for '@io_bazel_rules_go//go:def.bzl': The repository could not be resolved
INFO: Elapsed time: 19.702s                                                                                
INFO: 0 processes.                                                                                         
FAILED: Build did NOT complete successfully (15 packages loaded)                                           
    currently loading: @org_brotli//
@S8Cloud commented on GitHub (May 31, 2018): Changed org_brotli into commit `29dc2cce9090d6c92c908116e11373bc7fdc8ad1` ``` Starting local Bazel server and connecting to it... ................ ERROR: /root/nginx-bazel/BUILD:1432:1: error loading package '@org_brotli//': Extension file not found. Unable to load package for '@io_bazel_rules_go//go:def.bzl': The repository could not be resolved and referenced by '//:nginx-google-copyright' ERROR: Analysis of target '//:nginx-google.deb' failed; build aborted: error loading package '@org_brotli//': Extension file not found. Unable to load package for '@io_bazel_rules_go//go:def.bzl': The repository could not be resolved INFO: Elapsed time: 19.702s INFO: 0 processes. FAILED: Build did NOT complete successfully (15 packages loaded) currently loading: @org_brotli// ```
Author
Owner

@eustas commented on GitHub (May 31, 2018):

Oh, this looks like Bazel issue =( https://github.com/bazelbuild/bazel/issues/2391
In short: if in project A WORKSPACE something is defined, then project B that uses project A have to have same definition in WORKSPACE.

At referenced commit WORKSPACE was almost empty, just junit maven artifact reference. Now it has much more...

Going to investigate if there is a way to trick Bazel.

@eustas commented on GitHub (May 31, 2018): Oh, this looks like Bazel issue =( https://github.com/bazelbuild/bazel/issues/2391 In short: if in project A `WORKSPACE` something is defined, then project B that uses project A have to have same definition in `WORKSPACE`. At referenced commit `WORKSPACE` was almost empty, just `junit` maven artifact reference. Now it has much more... Going to investigate if there is a way to trick Bazel.
Author
Owner

@eustas commented on GitHub (May 31, 2018):

Could you try if #677 works for you?

@eustas commented on GitHub (May 31, 2018): Could you try if #677 works for you?
Author
Owner

@S8Cloud commented on GitHub (Jun 1, 2018):

Thank you for your great work, commit 03c34704c98ff62e230e26b5071fe46db97308eb works well with latest build of bazel!

@S8Cloud commented on GitHub (Jun 1, 2018): Thank you for your great work, commit `03c34704c98ff62e230e26b5071fe46db97308eb` works well with latest build of bazel!
Author
Owner

@eustas commented on GitHub (Jun 4, 2018):

Landed PR #677.

@eustas commented on GitHub (Jun 4, 2018): Landed PR #677.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#233