Skip to content

Commit 8422580

Browse files
devversionmmalerba
authored andcommitted
build: ensure no permission errors thrown in packages-dist script (#17566)
Bazel by default makes output files or tree artifacts readonly. This means that the packages-dist script fails in case release output has been built previously. This has only an effect in non-windows environments. We can reasonably fix this by making the folder/files writable before trying to delete them. This is similar to what Bazel internally does when deleting outputs of previous builds. see: https://github.com/bazelbuild/bazel/blob/07924e8260a447b69b18e8248203e1089b46962a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java#L1251
1 parent 1511fb0 commit 8422580

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/build-packages-dist.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ dirs=`echo "$targets" | sed -e 's/\/\/src\/\(.*\):npm_package/\1/'`
4444
# do this to ensure that the version placeholders are properly populated.
4545
for pkg in ${dirs}; do
4646
pkg_dir="${bazel_bin_path}/src/${pkg}/npm_package"
47-
rm -Rf ${pkg_dir}
47+
if [[ -d ${pkg_dir} ]]; then
48+
# Make all directories in the previous package output writable. Bazel by default
49+
# makes tree artifacts and file outputs readonly. This causes permission errors
50+
# when deleting the folder. To avoid these errors, we make all files writable.
51+
chmod -R u+w ${pkg_dir}
52+
rm -Rf ${pkg_dir}
53+
fi
4854
done
4955

5056
# Walk through each release package target and build it.

0 commit comments

Comments
 (0)