bazel-contrib / bazel-contrib/bazel-lib
[Bug]: `copy_to_directory` with `root_paths = ["**"]` removes leading character from filenames
- Dominant language
- Starlark
- Stars
- 182
- Forks
- 134
- Avg merge
- 1d 46m
- Merged PRs (30d)
- 1
Description
I'm trying to flatten some files in nested directories, including the top-level directory. For files in the top-level directory, the leading character is removed by `copy_to_directory`.
To reproduce, create a simple repo:
```bazel
# MODULE.bazel
module(name = "repro")
bazel_dep(name = "bazel_lib", version = "3.7.1")
```
```bazel
# BUILD.bazel
load("@bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
exports_files(["some_dir/some_file", "some_dir/some_other_file", "top_level_file"])
copy_to_directory(name = "copied", srcs = [":some_dir/some_file", ":some_dir/some_other_file", ":top_level_file"], root_paths = ["**"])
```
Then the test:
```
mkdir -p some_dir && touch touch some_dir/some{_other,}_file top_level_file
bazelisk build //:copied
ls -l bazel-bin/copied
```
This outputs the following, note `op_level_file` instead of the expected `top_level_file`:
```
total 0
-r-xr-xr-x 1 kai staff 0 Aug 31 12:43 op_level_file*
-r-xr-xr-x 1 kai staff 0 Aug 31 12:43 some_file*
-r-xr-xr-x 1 kai staff 0 Aug 31 12:43 some_other_file*
```
Contributor guide
Research direction
Start with the reproducer in BUILD.bazel and the copy_to_directory entry point, using MODULE.bazel to load bazel-lib and bazelisk build //:copied to confirm the filename issue. Trace how root_paths = ["**"] handles top-level and nested files; done when the output contains top_level_file unchanged alongside some_file and some_other_file.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100