What happened?
When the target repository (specified via --cwd) does not have a Bazel version that is compatible with the scip-lsp bazel version, an error occurs.
Expected Behavior
//bsp_server/scip_sync_util:scip_sync should use bazelisk to select the correct version of Bazel to use when running the bazel query command.
Observed Behavior
The PATH environment variable is modified (by bazelisk) before the initial bazel invocation to run the scip_sync tool to prefix the resolved bazel version. This pre-resolved bazel version is then used to run bazel query by the tool, thus ignoring the .bazelversion in the target repository.
This is confirmed with some simple debugging changes to bazel/execute_query.py before the bazel command is run.
print('--------')
for return_code, error_string, line in tqdm(utils.stream_output(command=["which", "bazel"], cwd=cwd, stderr=stderr, env_vars=env_vars)):
print(f"{return_code}, {error_string}, {line}")
print('--------')
import os
print(os.getenv("PATH"))
print('--------')
Steps to Reproduce
- Modify
.bazelversion in the target repo to be a version less than scip-lsp.
- (optional) Introduce a flag in the
.bazelrc that is incompatible with the scip-lsp version.
- Run
scip_sync on the target repository. Then, either:
- See the error caused by the different versions
- Observe the bazel version printed out at the beginning of the invocation
Some debugging changes will need to be made to bazel/execute_query.py to print the full output.
Environment
- Ubuntu 24.04.2
- Bazel Version: 7.4.2
Language Server Logs
SCIP Generation Logs
Logs with some additional debugging (mine)
$ bazel run //bsp_server/scip_sync_util:scip_sync -- --cwd=/pay/src/repo
INFO: Analyzed target //bsp_server/scip_sync_util:scip_sync (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //bsp_server/scip_sync_util:scip_sync up-to-date:
bazel-bin/bsp_server/scip_sync_util/scip_sync
INFO: Elapsed time: 0.124s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/bsp_server/scip_sync_util/scip_sync <args omitted>
Reading targets from .bazelproject file...
Syncing deps for targets: ['//src/java/com/company/mergeq/...:all', '//src/java/com/company/files/...', '//src/test/java/com/company/mergeq/...']
--------
cwd: /pay/src/repo
--------
env: None
--------
['bazel', 'query', '--output', 'streamed_jsonproto', '--order_output=no', '--query_file', '/pay/tmp/tmp1xcgv6kk']
--------
kind("java_library|java_import|java_test|jvm_import", deps("//src/java/com/company/mergeq/...:all" + "//src/java/com/company/files/..." + "//src/test/java/com/company/mergeq/...", 1))
--------
0it [00:00, ?it/s]0, None, /home/owner/.cache/bazelisk/downloads/sha256/52bb74f0880ee87b17e3a1aa41257d0dba9e9cb92df4e83f8f6c656a46df152d/bin/bazel
1it [00:00, 583.60it/s]
--------
/home/owner/.cache/bazelisk/downloads/sha256/52bb74f0880ee87b17e3a1aa41257d0dba9e9cb92df4e83f8f6c656a46df152d/bin:/pay/src/github.com/uber/scip-lsp/bin:...OMITTED...
--------
Running bazel query (approx 45s): 0 targets [00:00, ? targets/s]--------
return code: 2
erorr string: INFO: Reading rc options for 'query' from /pay/src/repo/.bazelrc:
ERROR: --incompatible_strict_conflict_checks=false :: Unrecognized option: --incompatible_strict_conflict_checks=false
--------
Running bazel query (approx 45s): 1 targets [00:00, 27.89 targets/s]
Found no targets to sync ...
SCIP Index Information
Reproducible Sample
No response
Additional Context
No response
Code of Conduct
What happened?
When the target repository (specified via
--cwd) does not have a Bazel version that is compatible with thescip-lspbazel version, an error occurs.Expected Behavior
//bsp_server/scip_sync_util:scip_syncshould use bazelisk to select the correct version of Bazel to use when running thebazel querycommand.Observed Behavior
The
PATHenvironment variable is modified (by bazelisk) before the initial bazel invocation to run thescip_synctool to prefix the resolved bazel version. This pre-resolved bazel version is then used to runbazel queryby the tool, thus ignoring the.bazelversionin the target repository.This is confirmed with some simple debugging changes to
bazel/execute_query.pybefore the bazel command is run.Steps to Reproduce
.bazelversionin the target repo to be a version less thanscip-lsp..bazelrcthat is incompatible with thescip-lspversion.scip_syncon the target repository. Then, either:Some debugging changes will need to be made to
bazel/execute_query.pyto print the full output.Environment
Language Server Logs
SCIP Generation Logs
SCIP Index Information
Reproducible Sample
No response
Additional Context
No response
Code of Conduct