Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to unset path on Windows for all actions #9467

Closed
ozio85 opened this issue Oct 2, 2019 · 9 comments
Closed

No way to unset path on Windows for all actions #9467

ozio85 opened this issue Oct 2, 2019 · 9 comments
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@ozio85
Copy link

ozio85 commented Oct 2, 2019

Description of the problem / feature request:

Currently it is not possible to unset the --action_env=PATH="" for all actions on Windows.

There is a difference between linux and windows in BazelRuleClassProvider.java, since on Windows you end up with (enabling strict_action_env):
env.put("PATH", pathOrDefault(os, null, shellExecutable));

But on Linux you simply leave the PATH empty:
env.put("PATH", null);

There is no way to use --action_env=PATH="" to unset the path for all actions (e.g. the internal Bazel Zipper tool gets the default path).

Feature requests: what underlying problem are you trying to solve with this feature?

If action_env=PATH is set, it should control the PATH

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Build any action that ends up with the default path.

What operating system are you running Bazel on?

Windows

What's the output of bazel info release?

0.29.1

Have you found anything relevant by searching the web?

GitHub issues:
#7026
#7976

@ozio85
Copy link
Author

ozio85 commented Oct 2, 2019

@buchgr asked me to ping you @meteorcloudy

@meteorcloudy
Copy link
Member

@ozio85 Thanks for reporting! Do you mean we should be able to set PATH to an empty value while --experimental_strict_action_env is enabled?

$ bazel build examples/py_native:bin -s --action_env=PATH= --experimental_strict_action_env
INFO: Build option --action_env has changed, discarding analysis cache.
INFO: Analyzed target //examples/py_native:bin (19 packages loaded, 100 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //examples/py_native:bin [action 'PythonZipper examples/py_native/bin.zip', configuration: 7207fdfe83323030023ba1b319d8be8d]
cd C:/src/tmp/wa6d46al/execroot/io_bazel
  SET PATH=
    SET RUNFILES_MANIFEST_ONLY=1
  external/bazel_tools/tools/zip/zipper/zipper.exe cC bazel-out/x64_windows-fastbuild/bin/examples/py_native/bin.zip @bazel-out/x64_windows-fastbuild/bin/examples/py_native/bin.zip-0.params
Target //examples/py_native:bin up-to-date:
  bazel-bin/examples/py_native/bin.exe
  bazel-bin/examples/py_native/bin.zip
INFO: Elapsed time: 0.466s, Critical Path: 0.01s
INFO: 1 process: 1 remote cache hit.
INFO: Build completed successfully, 3 total actions

Looks like it already works.

@ozio85
Copy link
Author

ozio85 commented Oct 3, 2019

No i mean that all actions are not affected by --action_env=PATH=""

bazel build //... --experimental_execution_log_file=log.txt --action_env=PATH=""

from log.txt

ž
0external/bazel_tools/tools/zip/zipper/zipper.exe
�cC
Sbazel-out/host/bin/external/MyPythonTool/parser.zip
]@bazel-out/host/bin/external/MyPythonTool/parser.zip-0.params�‡�
�PATH��C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\WindowsPowerShell\v1.0��
�RUNFILES_MANIFEST_ONLY��1� "¦�
Tbazel-out/host/bin/external/MyPythonTool/parser.temp�N
@c3a9d3e40c3e277e5c0533939c39889b63cf00dc5c32f2089b37d291c9a73f37�¬d��SHA-256"®�
\bazel-out/host/bin/external/MyPythonTool/parser.zip-0.params�N
@6fab84389b9c06c6d2fcc778ab84c9cfad68ee45405b0d6c92555cc0f8e49e5e�±���SHA-256"ƒ�
0external/bazel_tools/tools/zip/zipper/zipper.exe�O
@f714899c80ebcae78222eb81d3b3be9b44a25174e3aa38c78fc5852f04b86b11�€È	��SHA-256"’�
Aexternal/MyPythonTool/__init__.py�M
@a4b559aaf0e735ff5fa0647e1d79d7d85ed60b64d69b209335c51cb46f125c02����SHA-256"��
=external/MyPythonTool/base.py�N
@2d1a8ff1df5fcd3b6ab32165ffe3ed6a78514026a0041bf068f59b6528bef791�ó���SHA-256"‘�
?external/MyPythonTool/parser.py�N
@b7db744d733e5d03ba578674ec92ff9ad3b5ae4808f1948db15cc9754ddfd3b0�÷x��SHA-256*Sbazel-out/host/bin/external/MyPythonTool/parser.zip0�8�JXPythonZipper external/MyPythonTool/parser.zip [for host]RPythonZipperZ¥�
Sbazel-out/host/bin/external/MyPythonTool/parser.zip�N
@daf73564ab08ade06873eed9ffe754e8ba075efef2120de2bdbfdd2cdffada5f�€O��SHA-256b�local—

@aiuto aiuto added area-Windows Windows-specific issues and feature requests untriaged labels Oct 4, 2019
@meteorcloudy
Copy link
Member

$ bazel build examples/py_native:bin -s  --action_env=PATH=""
...
SUBCOMMAND: # //examples/py_native:bin [action 'PythonZipper examples/py_native/bin.zip']
cd C:/src/tmp/wa6d46al/execroot/io_bazel
  SET PATH=
    SET RUNFILES_MANIFEST_ONLY=1
  external/bazel_tools/tools/zip/zipper/zipper.exe cC bazel-out/x64_windows-fastbuild/bin/examples/py_native/bin.zip @bazel-out/x64_windows-fastbuild/bin/examples/py_native/bin.zip-0.params
Target //examples/py_native:bin up-to-date:
  bazel-bin/examples/py_native/bin.exe
  bazel-bin/examples/py_native/bin.zip
INFO: Elapsed time: 11.020s, Critical Path: 0.12s
INFO: 1 process: 1 remote cache hit.
INFO: Build completed successfully, 3 total actions

That's what I meant, it did work in my build with 0.29.1. Can you provide a correct log?

@ozio85
Copy link
Author

ozio85 commented Oct 9, 2019

Sorry it took some time.. but i had no time to write a repro:
repro.zip

Most of the actions are OK, but some are not, they get the default value listed in BazelRuleClassProvider.java:

ç�
0external/bazel_tools/tools/zip/zipper/zipper.exe
�cC
7bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.zip
A@bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.zip-0.params��
�PATH��
�RUNFILES_MANIFEST_ONLY��1� "Š�
8bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.temp�N
@10800e18f17a0cf3b0fe40ede4fbcd5422e286a81e0755eb7a226a4dcb292627�·c��SHA-256"’�
@bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.zip-0.params�N
@3143251cc74a8c6f2f221b48c26758815bfd1d68a2209a6e1b86a430be0341b7�Ð���SHA-256"ƒ�
0external/bazel_tools/tools/zip/zipper/zipper.exe�O
@f714899c80ebcae78222eb81d3b3be9b44a25174e3aa38c78fc5852f04b86b11�€È ��SHA-256"d
�MyTools/my_tool.py�N
@d17097973746bd4d5ff49899ce8bb9417fc612dd850c7ebf618df94c76fb92b4�����SHA-2567bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.zip0�8�J PythonZipper MyTools/my_tool.zipR PythonZipperZ‰�
7bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.zip�N
@ec9da5dbfcaa66120b77addf5b46480d12c60da7aa9e5490a76da4d90a1ca3cf�ë)��SHA-256b�localŒ�
0external/bazel_tools/tools/zip/zipper/zipper.exe
�cC
&bazel-out/host/bin/MyTools/my_tool.zip
0@bazel-out/host/bin/MyTools/my_tool.zip-0.params�‡�
PATH��C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\WindowsPowerShell\v1.0��
�RUNFILES_MANIFEST_ONLY��1� "y
'bazel-out/host/bin/MyTools/my_tool.temp�N
@0332a88fc1e9a10fda9f26b9238713b9eeb9efbec19b27b810bd3120dc90c977�µc��SHA-256"��
/bazel-out/host/bin/MyTools/my_tool.zip-0.params�N
@10f484e31cdacf2219871f5e5f1dd9724b89245d5a1c90be53e8cfb85e783512�¿���SHA-256"ƒ�
0external/bazel_tools/tools/zip/zipper/zipper.exe�O
@f714899c80ebcae78222eb81d3b3be9b44a25174e3aa38c78fc5852f04b86b11�€È ��SHA-256"d
�MyTools/my_tool.py�N
@d17097973746bd4d5ff49899ce8bb9417fc612dd850c7ebf618df94c76fb92b4�����SHA-256
&bazel-out/host/bin/MyTools/my_tool.zip0�8�J+PythonZipper MyTools/my_tool.zip [for host]R PythonZipperZx
&bazel-out/host/bin/MyTools/my_tool.zip�N
@c9fb03d164427c5855813ffd6677f43f4e5c372d53c5195b8a137acf869652d6�ë)��SHA-256b�localæ
&bazel-out/host/bin/MyTools/my_tool.exe
�--input
�myCfileInText.txt
�--output
-bazel-out/x64_windows-fastbuild/bin/myCFile.c��
�PATH��
�RUNFILES_MANIFEST_ONLY��1� "y
&bazel-out/host/bin/MyTools/my_tool.exe�O
@2a05592535d62614553724a35bc323368c59071dcd60069ff5d6459a12c80afa�’™
��SHA-256"X
/dev/null�K
@e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855��SHA-256"y
&bazel-out/host/bin/MyTools/my_tool.exe�O
@2a05592535d62614553724a35bc323368c59071dcd60069ff5d6459a12c80afa�’™
��SHA-256"d
�MyTools/my_tool.py�N
@d17097973746bd4d5ff49899ce8bb9417fc612dd850c7ebf618df94c76fb92b4�����SHA-256"x
&bazel-out/host/bin/MyTools/my_tool.zip�N
@c9fb03d164427c5855813ffd6677f43f4e5c372d53c5195b8a137acf869652d6�ë)��SHA-256"x
&bazel-out/host/bin/MyTools/my_tool.zip�N
@c9fb03d164427c5855813ffd6677f43f4e5c372d53c5195b8a137acf869652d6�ë)��SHA-256"`
�myCfileInText.txt�K
@e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855��SHA-256"d
�MyTools/my_tool.py�N
@d17097973746bd4d5ff49899ce8bb9417fc612dd850c7ebf618df94c76fb92b4�����SHA-256*-bazel-out/x64_windows-fastbuild/bin/myCFile.c0�8�J�Copy myCFile.cR�ActionZ|
-bazel-out/x64_windows-fastbuild/bin/myCFile.c�K
@e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855��SHA-256b�local

@laszlocsomor
Copy link
Contributor

I can repro this:

c:\src\gh9467>bazel --version
bazel 1.0.0

c:\src\gh9467>bazel build --disk_cache= --action_env=PATH= -s //...
INFO: Writing tracer profile to 'C:/_bazel/z3xw6kun/command.profile.gz'
INFO: Reading 'startup' options from c:\users\laszlocsomor\.bazelrc: --output_user_root=c:/_bazel
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=317
INFO: Options provided by the client:
  'build' options: --python_path=C:/python_27_amd64/files/python.exe
INFO: Reading rc options for 'build' from c:\src\gh9467\.bazelrc:
  'build' options: --experimental_execution_log_file=log.txt --incompatible_strict_action_env --action_env=PATH=
INFO: Reading rc options for 'build' from c:\users\laszlocsomor\.bazelrc:
  'build' options: --verbose_failures --announce_rc --python_path=c:/python37/python.exe --disk_cache=c:/src/_bzlcache --repository_cache=c:/src/_repocache
INFO: Analyzed 2 targets (15 packages loaded, 97 targets configured).
INFO: Found 2 targets...
SUBCOMMAND: # //MyTools:my_tool [action 'PythonZipper MyTools/my_tool.zip [for host]', configuration: 228e3440ba2c01da143c449ef8a04bfd]
cd C:/_bazel/z3xw6kun/execroot/__main__
  SET PATH=C:\msys64\usr\bin;C:\msys64\bin;C:\Windows;C:\Windows\System32;C:\Windows\System32\WindowsPowerShell\v1.0
    SET RUNFILES_MANIFEST_ONLY=1
  external/bazel_tools/tools/zip/zipper/zipper.exe cC bazel-out/host/bin/MyTools/my_tool.zip @bazel-out/host/bin/MyTools/my_tool.zip-0.params
SUBCOMMAND: # //MyTools:my_tool [action 'PythonZipper MyTools/my_tool.zip', configuration: 8d0083c65ec4f14bb97aacc2867745b3]
cd C:/_bazel/z3xw6kun/execroot/__main__
  SET PATH=
    SET RUNFILES_MANIFEST_ONLY=1
  external/bazel_tools/tools/zip/zipper/zipper.exe cC bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.zip @bazel-out/x64_windows-fastbuild/bin/MyTools/my_tool.zip-0.params
SUBCOMMAND: # //:myCFile [action 'Copy myCFile.c', configuration: 8d0083c65ec4f14bb97aacc2867745b3]
cd C:/_bazel/z3xw6kun/execroot/__main__
  SET PATH=
    SET RUNFILES_MANIFEST_ONLY=1
  bazel-out/host/bin/MyTools/my_tool.exe --input myCfileInText.txt --output bazel-out/x64_windows-fastbuild/bin/myCFile.c
INFO: Elapsed time: 10.394s, Critical Path: 0.64s
INFO: 3 processes: 3 local.
INFO: Build completed successfully, 12 total actions

@meteorcloudy
Copy link
Member

@ozio85 Thanks for providing the minimal repro case, I can reproduce this problem now. It seems this only happens with host configuration. We should fix this.

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@philwo
Copy link
Member

philwo commented Feb 8, 2021

Is this fixed by --host_action_env=PATH=?

@philwo philwo added the P3 We're not considering working on this, but happy to review a PR. (No assignee) label Feb 8, 2021
@meteorcloudy
Copy link
Member

Yes, this is fixed with --host_action_env=PATH=. I just verified on both macOS and Windows, they have the same expected behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

5 participants