-
Notifications
You must be signed in to change notification settings - Fork 305
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
Switching back and forth from terminal to IDE requires rebuilds #789
Comments
Do you have any custom flags in the |
No, and I'm using |
I have noticed in In Goland (pre Bazel Bazel 0.22) it's historically been due to IJ |
How are you launching the IDE? If you launch it via command line instead of the launcher icon, then it should inherit the same environment variables as bazel on the command line. If no other flags are added, then it's probably caused by different environment variables. |
Very interesting, we have been launching it through the Icon / JetBrains manager. I will give this a try. |
I also had this issue when launching IntelliJ from outside the terminal. Starting IJ from the terminal fixed it. We checked the environment variables, but there aren't any significant difference; so we are still clueless about the root causes. |
It was indeed due to the difference in the |
It appears that there are specific things still added by the Goland IJ terminal that are not present in the external shell's $PATH when launched via the command line. We have modified our workflow so this is not a problem and I believe some newer-bazel defaults regarding |
I found a situation where So do you think it's actually a Bazel bug that's causing the invalidation if the environment changes like this since it shouldn't actually matter? |
This also happens to me in C++ projects. Unless I use the terminal emulator in the tool window inside clion, bazel always discards cached results when switching between terminal and the IDE. There are diffs in the Unset in system terminal: Unset in IDE terminal: Set in both but empty in IDE terminal: Set to different value: When I copied the six env values other than ... and now that I've done that once, even in a new terminal and across calls to It's been an ongoing and especially insidious problem because some of my build rules call into existing non-bazel build processes and take a lot of CPU time to finish, yet will typically rerun every single time I go back and forth between system terminal and IDE sync. I'll see if I can figure out how to make it start reproducing again. edit: No dice after a reboot, things are continuing to work flawlessly as they have never before. I will check another dev machine. |
Yes, it's still reproducible from the other machine. 200+ rules rebuild each iteration going back and forth between syncing in the IDE and building in the system terminal. It's still happening, it seems to happen in the default configuration, and it's very unfun. |
On yet another machine, even switching back and forth between IDE sync and |
The IDE terminal still loads your rc script as an interactive shell. Does that machine have additional environment variables set there? What's the exact output that bazel gives when it tries to rebuild? Does it tell you which flag/variable changed? |
As far as I've seen there is no message indicating that cache is being discarded, it simply rebuilds a lot of things as if they were not there. I've looked pretty closely. The only extra things in my rc file are like I'm not entirely sure, but the items that are getting rebuilt seem to be, or be downstream of, |
You don't even get this message?
|
Not at all, no. |
Here's some example text I get from the Blaze Console during a sync (this is after syncing,
|
If there's any additional information I can provide I'm happy to do so. The |
We should probably move this over to http://github.com/bazelbuild/bazel, so they can help us figure out what caused the rebuild. |
AH! It's looking like there's a strong possibility that garbage left behind by python virtualenv scripts in $PATH are causing genrule builds to be discarded, and likewise every single thing that transitively depends upon them as well. It's a bit odd that it doesn't get logged, but it does look like this is probably the underlying cause. I will check on the laptop when I get home; hopefully it holds true there as well. |
Nope, no luck. I've done what I can to ensure that |
..........no, I realized the last thing I'd forgotten today. I have a script with I could probably file a feature request for genrules to log why they are being rebuilt. |
I had this problem and found it was indeed the environment By inspecting Moving my custom path from |
Yes, $PATH is one of the rebuild-triggering vars for essentially any genrule, which are often upstream of a lot of expensive compilation. |
How can I see the path? Bazel info does not show any path. Is there a flag to dump all the info that is used to detect the environment changed. |
If you run a build command with
...which as you can see shows explicitly setting PATH in a subshell before executing the command. |
Alternative, which I have actually done: just add |
Has anyone resolved this? I see the same issue with building protobuf when switching between goland and terminal. |
fwiw: I didnt experience this in goland 2019.1.x |
So there's the Just run
It doesn't tell you what your previous |
Why is the intellij bazel plugin using a different path? I don't understand the resolution. |
The IDE inherits its |
Isn't there some way to get deterministic builds with bazel? I understand this might be leading out of scope of this repository, but if you could point me in the right direction I would greatly appreciate it. |
The build is deterministic, given that the bazel calls out to some executables on your path for binaries that it doesn't bundle (I think things like cp, mv for genrules). It's just a possibility that it might affect build output, most of the time it doesn't. bazel is just overly eager in assuming a rebuild is necessary. You can even add an empty directory to your |
Yes, hermetic builds. Thanks! |
There's the But it looks like most actions just ignore |
Ah! Thanks for the pointer. I was able to resolve my original issue by adding this to my bazelrc.
|
**What this PR does / why we need it**: Switching between terminals ( `$PATH` change ) causes unnecessary rerun/rebuild. This PR fixes that issue by adding `--incompatible_strict_action_env` flag. ref: bazelbuild/intellij#789 **Which issue(s) this PR fixes**: Fixes # **Does this PR introduce a user-facing change?**: <!-- If no, just write "NONE" in the release-note block below. --> ```release-note NONE ``` This PR was merged by Kapetanios.
Whenever I run a bazel build in the terminal and then switch to intellij and resync the project, it does a full rebuild. It says the options have changed so it's discarding the cache.
Looking at the options it sets,
--tool_tag
stands out as an obvious one that is in theaffects_output
section of the Bazel CLI docs, so could that be causing it? There are others as well.How necessary are these and are there any workarounds or improvements that could be made to make switching back and forth a little easier/faster?
If it sounds like I'm talking crazy talk because this isn't happening for you, I can give more details about the project, if you point me in the right direction to start.
The text was updated successfully, but these errors were encountered: