Skip to content

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

Open
@MohitBhar

Description

@MohitBhar

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 repo.
  • Remove examples/ from .bazelignore.
  • Modify the architecture in the example target here:
--- 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions