Skip to content

Support other output modes than 0555 #5588

Open

Description

@wking

Description of the problem / feature request:

When building tarballs with pkg_tar, the output tarball has a 0555 mode. But tarballs are generally not going to be executable. I think the default mode should be 0666 or, if you want to be very conservative 0444. In both those cases, it would be nice to respect the user's umask, as long as it did not interfere with reproducible builds. An alternative would be to provide an explicit pkg_tar parameter that functions similarly to the existing mode (although mode is for files packaged inside the tarball, not for the tarball itself, #2925).

Feature requests: what underlying problem are you trying to solve with this feature?

Claiming that output tarballs are executable makes it harder to auto-complete sibling paths that are executable. And if you attempt to execute the tarball, I think an EPERM is more obvious than "cannot execute binary file".

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

$ bazel version
Build label: 0.15.0- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jun 27 14:43:20 2018 (1530110600)
Build timestamp: 1530110600
Build timestamp as int: 1530110600
$ cat WORKSPACE 
workspace(name = "test")
$ cat BUILD.bazel 
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

pkg_tar(
    name = "test",
    srcs = glob(
        ["*.txt"],
        exclude_directories = 1,
    ),
    mode = "0666",
)
$ touch text.txt 
$ bazel build test
Starting local Bazel server and connecting to it...
........
INFO: Analysed target //:test (16 packages loaded).
INFO: Found 1 target...
Target //:test up-to-date:
  bazel-bin/test.tar
INFO: Elapsed time: 1.360s, Critical Path: 0.11s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed successfully, 6 total actions
$ ls -l bazel-bin/test.tar 
-r-xr-xr-x. 1 wking wking 10240 Jul 12 21:49 bazel-bin/test.tar

What operating system are you running Bazel on?

RHEL 7.5 (Linux).

What's the output of bazel info release?

$ bazel info release
release 0.15.0- (@non-git)

If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.

Installed from COPR.

Have you found anything relevant by searching the web?

#2925 is similar, but (as mentioned above), it's about the content of the tarball and not the tarball itself. I didn't see anything on SO or bazel-discuss@.

Activity

  1. added a commit that references this issue on Jul 13, 2018
  2. aehlig commented on Jul 18, 2018

    @aehlig
    Contributor

    The output of pkg_tar is an artefact as any other artefact generated by bazel hence gets the same permissions. So, while it is questionable that outputs always have permissions 0555, this has nothing to do with pkg_tar. The most simple way to demonstrate that generic bazel behavior is a BUILD file with the following contents.

    genrule(
      name = "hello",
      outs = ["hello.txt"],
      cmd = "echo Hello World > $@ && chmod 0444 $@",
    )
    

    Even then, bazel build :hello will generate a file with permissions 0555.

  3. removed their assignment
    on Jul 18, 2018
  4. changed the title [-]pkg_tar makes output mode 0555[/-] [+]feature reqeust: support other output modes than 0555[/+] on Jul 18, 2018
  5. added
    P4
    on Jul 18, 2018
  6. changed the title [-]feature reqeust: support other output modes than 0555[/-] [+]feature request: support other output modes than 0555[/+] on Jul 18, 2018
  7. 30 remaining items

  8. aiuto commented on May 24, 2023

    @aiuto

    FWIW, rules_pkg has this capability. The ancient (and deprecated) pkg_tar from @bazel_tools does not.

  9. removed
    stale
    on May 25, 2023
  10. github-actions commented on Jul 29, 2024

    @github-actions

    Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

  11. added
    stale
    on Jul 29, 2024
  12. tmccombs commented on Jul 29, 2024

    @tmccombs

    Bump

  13. removed
    stale
    on Jul 30, 2024
  14. github-actions commented on Oct 3, 2025

    @github-actions

    Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

  15. added
    stale
    on Oct 3, 2025
  16. github-actions commented on Jan 1, 2026

    @github-actions

    This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!

  17. tmccombs commented on Jan 1, 2026

    @tmccombs

    .

  18. reopened this on Jan 1, 2026
  19. removed
    stale
    on Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3team-Coretype: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions