I have a workflow where I may bazel build from one or more SSH connections. When I build from one SSH connection and then switch to the other, the bazel daemon restarts and rebuilds all dependencies, even though the bazel build options have not changed.
Do you run in different directories? Different users?
Nope--same user, same directory.
Difference in the environment?
On Fri, Dec 2, 2016, 6:54 PM kayasoze notifications@github.com wrote:
Nope--same user same directory.
—
You are receiving this because you were assigned.Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/bazel/issues/2153#issuecomment-264517870,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADjHf-12RTUNeJTEgI4IXd1e7Y01QsP-ks5rEFtagaJpZM4LA0GU
.
One is an interactive shell and one is not, thus picking up slightly different sets of environment variables, such as $PATH, $LANG, $VISUAL, $LS_COLORS etc. However, they still end up executing the same Bazel binary, and bazel info shows the same server PID. They're even multiplexed over the same SSH session. The only major difference between sessions is that one is attached to a tty and the other is not.
Trial and error has shown that the culprit is $PATH; if it changes, cached artifacts seem to be invalidated, even when the $PATH changes are benign, and don't effect hermeticity of the build.
In fact, even if $PATH changed compiler paths, etc. I'd expect Bazel to preserve the artifact cache, as the compiler toolchains it uses should not depend on the user's $PATH.
This is WAI. Set --action_env PATH=YourPath in your bazelrc to avoid this behaviour.
I can reproduce the bug with different $PATHs even with the following in my .bazelrc:
# Prevent PATH changes from invalidating builds when switching between
# interactive and non-interactive shells.
build --action_env=PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
test --action_env=PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
I can't use common because it interferes with bazel query. So far, the only reliable way of preventing this issue is to make sure $PATH is identical across invocations, so perhaps this bug should be reopened.
Still happens with Bazel 1.2.0. Doesn't matter that you set the action_env in your .bazelrc file if the PATH changes you're getting a rebuild.
Most helpful comment
I can reproduce the bug with different $PATHs even with the following in my .bazelrc:
I can't use
commonbecause it interferes withbazel query. So far, the only reliable way of preventing this issue is to make sure $PATH is identical across invocations, so perhaps this bug should be reopened.