bazelbuild / bazelbuild/rules_pkg

pkg_rpm fails on macOS 15.4+ with "No such file or directory" error

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

Description

`rules_pkg` RPM builds started failing on macOS (Apple Silicon) after upgrading to macOS 15.4.1 and continues to fail on macOS Sequoia (15.5). Reinstalling bazelisk and rpm through brew didn't help. The issue seems to be related to symbolic link handling and affects builds using pkg_rpm.

**Steps to Reproduce:**

- Use macOS 15.4.1+ (Apple Silicon).
- Clone the [rules_pkg](https://github.com/bazelbuild/rules_pkg) repo.
- Remove `examples/` from [.bazelignore](https://github.com/bazelbuild/rules_pkg/blob/c590e619313f3227c06541b00deb6074680b8922/.bazelignore#L5).
- Modify the architecture in the example target [here](https://github.com/bazelbuild/rules_pkg/blob/c590e619313f3227c06541b00deb6074680b8922/examples/rpm/nospecfile/BUILD#L33):
```
--- a/examples/rpm/nospecfile/BUILD
+++ b/examples/rpm/nospecfile/BUILD
@@ -30,7 +30,7 @@
srcs = [
":rpm_files",
],
- architecture = "x86_64",
+ architecture = "aarch64",
```
- Run:
```bazel build examples/rpm/nospecfile:test-rpm```

**Observed Error:**

```
cp: examples/rpm/nospecfile/BUILD: No such file or directory
```

**Suspected Cause:**
After the macOS upgrade, it appears symbolic link resolution by Bazel may have changed or broken in this context.

**Proposed Fix:**
Using an absolute path or adjusting the working directory before the cp command resolves the issue temporarily.

```
--- a/pkg/rpm_pfg.bzl
+++ b/pkg/rpm_pfg.bzl
@@ -73,13 +73,13 @@
_INSTALL_FILE_STANZA_FMT = """
install -d "%{{buildroot}}/$(dirname '{1}')"
-cp '{0}' '%{{buildroot}}/{1}'
+cd %{{buildroot}}/.. && cp 'BUILD/{0}' '%{{buildroot}}/{1}'
chmod +w '%{{buildroot}}/{1}'
""".strip()

_INSTALL_FILE_STANZA_FMT_FEDORA40_DEBUGINFO = """
install -d "%{{buildroot}}/$(dirname '{1}')"
-cp '../{0}' '%{{buildroot}}/{1}'
+cd %{{buildroot}}/.. && cp 'BUILD/{0}' '%{{buildroot}}/{1}'
chmod +w '%{{buildroot}}/{1}'
""".strip()
```
While this workaround avoids the immediate error, the build still fails in later stages.

**Request:**
Please help investigate and suggest a proper fix for symbolic file handling under macOS 15.4+ with Apple chips.

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.