bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
221 stars 174 forks source link

examples do not work #780

Closed sena-otus closed 11 months ago

sena-otus commented 11 months ago

$ cd rules_pkg/examples/naming_package_files


$ bazel build :example1
ERROR: Traceback (most recent call last):
    File "/home/sena/src/otus/dz-1/rules_pkg/examples/naming_package_files/BUILD", line 62, column 8, in <toplevel>
        pkg_tar(
    File "/home/sena/.cache/bazel/_bazel_sena/4ef8dcc7de687de9e4c3dbc2406ceb8c/external/rules_pkg/pkg/private/tar/tar.bzl", line 367, column 38, in pkg_tar
        private_stamp_detect = select({
Error in select: select: got Label for dict key, want a label string
ERROR: Skipping ':example1': no such target '//:example1': target 'example1' not declared in package '' defined by /home/sena/src/otus/dz-1/rules_pkg/examples/naming_package_files/BUILD
WARNING: Target pattern parsing failed.
ERROR: no such target '//:example1': target 'example1' not declared in package '' defined by /home/sena/src/otus/dz-1/rules_pkg/examples/naming_package_files/BUILD
INFO: Elapsed time: 0,035s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
$ bazel build :example2
Starting local Bazel server and connecting to it...
ERROR: Traceback (most recent call last):
    File "/home/sena/src/otus/dz-1/rules_pkg/examples/naming_package_files/BUILD", line 62, column 8, in <toplevel>
        pkg_tar(
    File "/home/sena/.cache/bazel/_bazel_sena/4ef8dcc7de687de9e4c3dbc2406ceb8c/external/rules_pkg/pkg/private/tar/tar.bzl", line 367, column 38, in pkg_tar
        private_stamp_detect = select({
Error in select: select: got Label for dict key, want a label string
ERROR: Skipping ':example2': no such target '//:example2': target 'example2' not declared in package '' defined by /home/sena/src/otus/dz-1/rules_pkg/examples/naming_package_files/BUILD
WARNING: Target pattern parsing failed.
ERROR: no such target '//:example2': target 'example2' not declared in package '' defined by /home/sena/src/otus/dz-1/rules_pkg/examples/naming_package_files/BUILD
INFO: Elapsed time: 1,262s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
$ aptitude show bazel-bootstrap
Package: bazel-bootstrap                 
Version: 4.2.3+ds-9
aiuto commented 11 months ago

Bazel 4.x is several years out of date. If you must stick with that, my advice is use an older version of rules_pkg, from when 4.x was still current.

sena-otus commented 11 months ago

Bazel 4.x is several years out of date. If you must stick with that, my advice is use an older version of rules_pkg, from when 4.x was still current.

I did not know that it is out of date. I want to learn bazel and installed one from the current stable Debian 12 (bookworm). It is strange that they ship the outdated version. What will be the recommended way to install it on Debian?

sena-otus commented 11 months ago

Bazel 4.x is several years out of date. If you must stick with that, my advice is use an older version of rules_pkg, from when 4.x was still current.

Debian package is referenced on Basel website. May be they should highlight that package shipped with Debian is outdated and must not be used, instead of just linking to Debian site. Should I report that?

sena-otus commented 11 months ago

Bazel 4.x is several years out of date. If you must stick with that, my advice is use an older version of rules_pkg, from when 4.x was still current.

It will be also good (remember examples are for newbies!) if you will check bazel version in BUILD script and produce some meaningful error message like "Your are using bazel 4.2.3 it is not supported, please upgrade to 10.x".

At least in CMake you can do that.

aiuto commented 11 months ago

Bazel 4.x is several years out of date. If you must stick with that, my advice is use an older version of rules_pkg, from when 4.x was still current.

Debian package is referenced on Basel website. May be they should highlight that package shipped with Debian is outdated and must not be used, instead of just linking to Debian site. Should I report that?

You could. The Bazel team does not create the Debian packages, so we don't know if they are out of date.

aiuto commented 11 months ago

I opened the issue in the Bazel repo. https://github.com/bazelbuild/bazel/issues/20133

sena-otus commented 11 months ago

What about checking bazel version in BUILD sproduce some meaningful error message like "Your are using bazel 4.2.3 it is not supported, please upgrade to 10.x"?

aiuto commented 11 months ago

This is the wrong place to do that. It should be a bazel feature.

One rough idea is that WORKSPACE and MODULE.bazel should have an ability to set minimal bazel version. If you try to build with an early bazel version it fails there.