Skip to content

Commit 32e8fb7

Browse files
vadikmironovclaudeaignasgemini-code-assist[bot]rickeylev
authored
fix: use powershell.exe instead of pwsh.exe for build_data_writer (bazel-contrib#3553)
Stock Windows ships with Windows PowerShell 5.1 (powershell.exe) but not PowerShell 7+ (pwsh.exe). Using pwsh.exe causes builds to fail on machines without PowerShell 7 installed. Also adds -ExecutionPolicy Bypass since Windows PowerShell defaults to Restricted policy which blocks .ps1 script execution. Fixes bazel-contrib#3552 --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Richard Levasseur <richardlev@gmail.com>
1 parent abe2699 commit 32e8fb7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

python/private/py_executable.bzl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,17 @@ def _write_build_data(ctx):
13691369
action_args = ctx.actions.args()
13701370
writer_file = ctx.files._build_data_writer[0]
13711371
if writer_file.path.endswith(".ps1"):
1372-
action_exe = "pwsh.exe"
1373-
action_args.add("-File")
1374-
action_args.add(writer_file)
1372+
# powershell.exe is used for broader compatibility
1373+
# It is installed by default on most Windows versions
1374+
action_exe = "powershell.exe"
1375+
action_args.add_all([
1376+
# Bypass execution policy is needed because,
1377+
# by default, Windows blocks ps1 scripts.
1378+
"-ExecutionPolicy",
1379+
"Bypass",
1380+
"-File",
1381+
writer_file,
1382+
])
13751383
inputs.add(writer_file)
13761384
else:
13771385
action_exe = ctx.attr._build_data_writer[DefaultInfo].files_to_run

0 commit comments

Comments
 (0)