title: How to make sure a build doesn't depend on two different versions of an external dependency?
body: <p>We are in the process of Tensorflow 2.x migration. And we define our tensorflow dependency as for example @tensorflow1// and @tensorflow2//.</p>
  <p>We notice that if both @tensorflow1// and @tensorflow2// are in the dependency tree, via <code>data</code><a href="https://docs.bazel.build/versions/main/be/common-definitions.html#typical.data" rel="nofollow noreferrer">1</a> the build can succeeded but the final bazel run-file will be nondeterministic: it can be either TF1 or TF2 depending on which is build latter.</p>
  <p>I wonder if there is any way to fail the build if both @tensorflow1// and @tensorflow2// is in the dependency graph?</p>
  <p>Note that if TF1 and TF2 are referred via the <code>deps</code><a href="https://docs.bazel.build/versions/main/be/common-definitions.html#typical.deps" rel="nofollow noreferrer">2</a> section the build will fail with conflicting namespace but it won't if they are referred via the <code>data</code><a href="https://docs.bazel.build/versions/main/be/common-definitions.html#typical.data" rel="nofollow noreferrer">1</a> section.</p>
  <p>Thanks,
  Muyang</p>