Repository: angular
Issue: `--config remote` and `--config debug` are incompatible
Labels: workaround2: non-obvious,area: dev-infra,type: confusing,P3

# 🐞 bug report

### Affected Package
<!-- Can you pin-point one or more @angular/* packages as the source of the bug? -->
<!-- ✍️edit: --> The issue is caused by `yarn bazel`


### Is this a regression?

<!-- Did this behavior use to work in the previous version? -->
<!-- ✍️--> I don't know, I've never tried this before.


### Description

<!-- ✍️--> I had `build --config remote` in my `.bazelrc.user` which I added a long time ago for RBE. Today I needed to debug a test and was pointed at `--config debug`. When I tried to use it however, I immediately got an error that the test timeout was too long:

```
$ yarn bazel test --config debug //packages/compiler-cli/test/ngtsc
yarn run v1.22.4
$ /home/douglasparker/Source/ng/node_modules/.bin/bazel test --config debug //packages/compiler-cli/test/ngtsc
INFO: Invocation ID: ef001969-b478-4b86-994d-db49c0031214
WARNING: Streamed test output requested. All tests will be run locally, without sharding, one at a time
INFO: Build options --crosstool_top, --define, --extra_execution_platforms, and 8 more have changed, discarding analysis cache.
DEBUG: /home/douglasparker/.cache/bazel/_bazel_douglasparker/aef1a2fc4785727e712f458c2fbf89e6/external/bazel_toolchains/rules/rbe_repo.bzl:491:10: Bazel 3.2.0 is used in rbe_ubuntu1604_angular.
WARNING: /home/douglasparker/.cache/bazel/_bazel_douglasparker/aef1a2fc4785727e712f458c2fbf89e6/external/remote_java_tools_linux/BUILD:671:11: in hdrs attribute of cc_library rule @remote_java_tools_linux//:combiners: Artifact 'external/remote_java_tools_linux/java_tools/src/tools/singlejar/zip_headers.h' is duplicated (through '@remote_java_tools_linux//:transient_bytes' and '@remote_java_tools_linux//:zip_headers'). Since this rule was created by the macro 'cc_library', the error might have been caused by the macro implementation
INFO: Analyzed target //packages/compiler-cli/test/ngtsc:ngtsc (7 packages loaded, 5022 targets configured).
INFO: Found 1 test target...
ERROR: /home/douglasparker/Source/ng/packages/compiler-cli/test/ngtsc/BUILD.bazel:24:18: Couldn't build file packages/compiler-cli/test/ngtsc/ngtsc/test.log:  failed (Exit 34): INVALID_ARGUMENT: Invalid arguments: 
  "action.timeout": Timeout 2h46m39s exceeds maximum timeout of 1h0m0s. Note: Remote connection/protocol failed with: execution failed INVALID_ARGUMENT: Invalid arguments: 
  "action.timeout": Timeout 2h46m39s exceeds maximum timeout of 1h0m0s
Target //packages/compiler-cli/test/ngtsc:ngtsc up-to-date:
  dist/bin/packages/compiler-cli/test/ngtsc/ngtsc.sh
  dist/bin/packages/compiler-cli/test/ngtsc/ngtsc_loader.js
  dist/bin/packages/compiler-cli/test/ngtsc/ngtsc_require_patch.js
INFO: Elapsed time: 26.685s, Critical Path: 24.02s
INFO: 46 processes: 44 remote cache hit, 2 remote.
FAILED: Build did NOT complete successfully
//packages/compiler-cli/test/ngtsc:ngtsc                              NO STATUS

FAILED: Build did NOT complete successfully
error Command failed with exit code 34.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

I updated the [`--config debug`](https://github.com/angular/angular/blob/5a733629b531083fd35563ee5bc286a8954da5fc/.bazelrc#L2) definition to use `--test_timeout=3600` to avoid this error. After that however, the test just hangs. It does not execute and does not print out that it is waiting for a debugger.

```
$ yarn bazel test --config debug //packages/compiler-cli/test/ngtsc
yarn run v1.22.4
$ /home/douglasparker/Source/ng/node_modules/.bin/bazel test --config debug //packages/compiler-cli/test/ngtsc
INFO: Invocation ID: bd00ec13-83e3-44be-9198-e94cbba45ccb
WARNING: Streamed test output requested. All tests will be run locally, without sharding, one at a time
INFO: Build option --test_timeout has changed, discarding analysis cache.
DEBUG: /home/douglasparker/.cache/bazel/_bazel_douglasparker/aef1a2fc4785727e712f458c2fbf89e6/external/bazel_toolchains/rules/rbe_repo.bzl:491:10: Bazel 3.2.0 is used in rbe_ubuntu1604_angular.
WARNING: /home/douglasparker/.cache/bazel/_bazel_douglasparker/aef1a2fc4785727e712f458c2fbf89e6/external/remote_java_tools_linux/BUILD:671:11: in hdrs attribute of cc_library rule @remote_java_tools_linux//:combiners: Artifact 'external/remote_java_tools_linux/java_tools/src/tools/singlejar/zip_headers.h' is duplicated (through '@remote_java_tools_linux//:transient_bytes' and '@remote_java_tools_linux//:zip_headers'). Since this rule was created by the macro 'cc_library', the error might have been caused by the macro implementation
INFO: Analyzed target //packages/compiler-cli/test/ngtsc:ngtsc (1 packages loaded, 5022 targets configured).
INFO: Found 1 test target...
[120 / 121] Testing //packages/compiler-cli/test/ngtsc:ngtsc; 300s remote
```

It was some time before I realized the problem was `build --config remote` in my `.bazelrc.user` file.

I understand that debugging like this requires the test to be executed locally, so `--config remote` doesn't really apply. However, it is a really easy foot-gun that leads to some pretty unintuitive behavior. Ideally there would be a way to:

1. Make `--config debug` take precedence over `--config remote`.
    * I'm not sure exactly how this could work, but I guess any flags in `--config debug` would be **probably** win over `--config remote`, since the former is a command line flag while the later is from a `.bazelrc` file?
2. Warn or error when these two flags are used together.
    * Even less sure if this is possible. No idea exactly how that would work.

Hopefully there's some way we can catch this particular error without just having tests hang forever.