bazelbuild / bazelbuild/rules_pkg

package_dir unexpectedly being stripped from files when it matches Bazel package name

Open
#905 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Starlark
Stars
253
Forks
221
Avg merge
10h 33m
Merged PRs (30d)
1

Description

Minimal reproducible example here: https://github.com/sloretz/rules_pkg_package_dir

Our codebase has a macro that calls `pkg_tar` with `strip_prefix` and `package_dir` set to hardcoded values, sort of like this:

```Python
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

def macro_using_pkg_tar(name, srcs, **kwargs):
pkg_tar(
name = name,
extension = "tar.gz",
compressor_args = "--fast",
strip_prefix = "/",
package_dir = "/data",
srcs = srcs,
**kwargs
)
```

If I call that macro in the Bazel package `//tools` then the file in the archive is put at `data/tools/foo.txt`. If I call the same macro in the Bazel package `//data` then the file in the archive is `data/foo.txt` with rules_pkg `1.0.1`, and `data/data/foo.txt` with rules_pkg `0.9.1`.

I expect the `0.9.1` behavior. Any ideas on workarounds to prevent `package_dir` from being stripped in `1.0.1`?

Possibly caused by #749?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.