From 9aaddd28acd901b3ebb203c224a38167b80455d1 Mon Sep 17 00:00:00 2001 From: Jeff Hodsdon Date: Mon, 15 Dec 2025 12:52:07 +0100 Subject: [PATCH] fix: unset RUNFILES_MANIFEST_FILE for subprocesses (rules_python 1.7+) When bundletool_experimental invokes codesigningtool via os.system(), the inherited RUNFILES_MANIFEST_FILE causes codesigningtool's bootstrap to use the wrong runfiles root. Unsetting it allows each py_binary to discover its own runfiles. Fixes: https://github.com/bazelbuild/rules_apple/issues/2843 --- tools/bundletool/bundletool_experimental.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bundletool/bundletool_experimental.py b/tools/bundletool/bundletool_experimental.py index 7f0a487859..4a57d05e02 100644 --- a/tools/bundletool/bundletool_experimental.py +++ b/tools/bundletool/bundletool_experimental.py @@ -290,7 +290,7 @@ def _post_process_bundle(self, bundle_root, post_processor): # Configure the TREE_ARTIFACT_OUTPUT environment variable to the path of the # bundle, but keep the work_dir for compatibility with the bundletool post # processing. - exit_code = os.system('TREE_ARTIFACT_OUTPUT="%s" %s "%s"' % + exit_code = os.system('unset RUNFILES_MANIFEST_FILE; TREE_ARTIFACT_OUTPUT="%s" %s "%s"' % (bundle_root, post_processor, work_dir)) if exit_code: raise PostProcessorError(exit_code) @@ -304,7 +304,7 @@ def _sign_bundle(self, bundle_root, command_lines): executed in the bundle to sign it. """ exit_code = os.system( - 'WORK_DIR=%s\n%s' % (shlex.quote(bundle_root), command_lines) + 'unset RUNFILES_MANIFEST_FILE; WORK_DIR=%s\n%s' % (shlex.quote(bundle_root), command_lines) ) if exit_code: raise CodeSignError(exit_code)