Why does Bazel rebuild when switching terminals?

597 views
Skip to first unread message

Shareef Jalloq

unread,
Dec 7, 2022, 10:02:05 AM12/7/22
to bazel-discuss
I'm working in the same workspace in multiple terminals and am finding that Bazel keeps rebuilding targets that haven't changed.  If I run 'bazel build //my:target' multiple times in one terminal it correctly caches.  When I switch terminal and run the same command it rebuilds everything including the protoc compiler.

What is going on?

Shareef Jalloq

unread,
Dec 7, 2022, 11:08:15 AM12/7/22
to bazel-discuss
Hmm, the --explain switch is kinda useful.

Shareef Jalloq

unread,
Dec 7, 2022, 11:09:48 AM12/7/22
to bazel-discuss
Meh, clicked send by mistake....

this seems to be due to differences in the PATH variable between a terminal and one within VSCode.  What's the correct way to tell Bazel to not recompile everything if the PATH is different?  My Google foo has failed me.

James Sharpe

unread,
Dec 7, 2022, 11:12:19 AM12/7/22
to Shareef Jalloq, bazel-discuss
--incompatible_strict_action_env is the option that you want: 
https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env

James Sharpe | Software Architecture & Security | Zenotech
Papercut
Email:
james....@zenotech.com
Zenotech LTD - Simulation Unlimited
Web:
www.zenotech.com


Papercut
linkedin:Twitter:Location:

Company Registration No : 07926926 | VAT No : 128198591

Registered Office : 1 Larkfield Grove, Chepstow, Monmouthshire, NP16 5UF, UK

Address : Bristol & Bath Science Park, Dirac Cres, Emersons Green, Bristol BS16 7FR



--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/4ce2492b-7afd-4d21-965c-bac16dbe1436n%40googlegroups.com.

Jeremy Volkman

unread,
Dec 8, 2022, 7:03:17 AM12/8/22
to Shareef Jalloq, bazel-discuss
It sounds like the environment differs between your various terminals and that is leaking through (which is, unfortunately, the default). Do you have --incompatible_strict_action_env enabled? https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env

On Wed, Dec 7, 2022 at 7:02 AM Shareef Jalloq <sha...@jalloq.co.uk> wrote:
I'm working in the same workspace in multiple terminals and am finding that Bazel keeps rebuilding targets that haven't changed.  If I run 'bazel build //my:target' multiple times in one terminal it correctly caches.  When I switch terminal and run the same command it rebuilds everything including the protoc compiler.

What is going on?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Shareef Jalloq

unread,
Dec 8, 2022, 8:32:51 AM12/8/22
to bazel-discuss
Thanks both.  I thought I tried that already but will have another look.  Perhaps I didn't set it correctly.

Shareef Jalloq

unread,
Dec 9, 2022, 8:01:27 AM12/9/22
to bazel-discuss
Nope, this doesn't work unless I'm using the argument incorrectly.  I added build:opt --incompatible_strict_action_env to my .bazelrc.  Updating the PATH means that it re-compiles everything.

Shareef Jalloq

unread,
Dec 9, 2022, 8:06:21 AM12/9/22
to bazel-discuss
D'oh.  build --incompatible_strict_action_env works!  Thanks.
Reply all
Reply to author
Forward
0 new messages