Skip to content

Commit 462f3ae

Browse files
committed
build: ensure no permission errors thrown in packages-dist script
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 50514b2 commit 462f3ae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/build-packages-dist.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,14 @@ dirs=`echo "$targets" | sed -e 's/\/\/src\/\(.*\):npm_package/\1/'`
4343
# a workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1219. We need to
4444
# do this to ensure that the version placeholders are properly populated.
4545
for pkg in ${dirs}; do
46-
pkg_dir="${bazel_bin_path}/src/${pkg}/npm_package"
47-
rm -Rf ${pkg_dir}
46+
if [[ -d ${pkg} ]]; then
47+
pkg_dir="${bazel_bin_path}/src/${pkg}/npm_package"
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)