Repository navigation
Description
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.tarWhat 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
BUILD.bazel: Explicitly set file modes
aehlig commentedon Jul 18, 2018
The output of
pkg_taris an artefact as any other artefact generated by bazel hence gets the same permissions. So, while it is questionable that outputs always have permissions0555, this has nothing to do withpkg_tar. The most simple way to demonstrate that genericbazelbehavior is aBUILDfile with the following contents.Even then,
bazel build :hellowill generate a file with permissions0555.[-]pkg_tar makes output mode 0555[/-][+]feature reqeust: support other output modes than 0555[/+][-]feature reqeust: support other output modes than 0555[/-][+]feature request: support other output modes than 0555[/+]30 remaining items
aiuto commentedon May 24, 2023
FWIW,
rules_pkghas this capability. The ancient (and deprecated)pkg_tarfrom@bazel_toolsdoes not.github-actions commentedon Jul 29, 2024
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.
tmccombs commentedon Jul 29, 2024
Bump
github-actions commentedon Oct 3, 2025
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.
dist: add support for configurable file permissions
dist: add support for configurable file permissions (second effort)
github-actions commentedon Jan 1, 2026
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post
@bazelbuild/triagein a comment here and we'll take a look. Thanks!tmccombs commentedon Jan 1, 2026
.