Skip to content
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

Java Projects contains (empty) Referenced Libraries instead of Bazel Maven JAR dependencies #103

Closed
vorburger opened this issue Feb 19, 2024 · 10 comments

Comments

@vorburger
Copy link
Contributor

After a Clean Java Language Server Workspace for #102,

when I open e.g. common/common/src/main/java/dev/enola/common/io/resource/FileResource.java,

which is an example intentionally chosen because that common/common "module" (Bazel target) doesn't depend on others,

then those com.google.common.io Guava imports don't resolve and are red.

In the "Java Projects" view, there is an (empty) Referenced Libraries, instead of Bazel Maven JAR dependencies.

enola-dev/enola#431 couldn't be the root cause of this, could it? There is no error in the .log about it...

Perhaps it would be useful to add some additional catch and log in the part of the code which sets that up?

@vorburger
Copy link
Contributor Author

@guw FYI at least on 1 of my computers (I'm not sure what's different on this one) I can reproduce this problem reliably, it's still there even after I Clean Java Language Server Workspace again... let me know if I can help providing any additional debugging.

Perhaps it would be useful to add some additional catch and log in the part of the code which sets that up?

Here's the log.txt - but it's "boring"?

@vorburger
Copy link
Contributor Author

vorburger commented Feb 20, 2024

@guw FYI at least on 1 of my computers (I'm not sure what's different on this one) I can reproduce this problem reliably,

@guw I'm facing this on one machine, which blocks me from working in a certain environment (but it works fine on another computer); here is some additional information from my machine where this always happens, the Java Build Status shows:

17ec1abd enola> bazel info [Done]
de2ff68f Initialize Workspace [Done]
a0f88908 Synchronizing projects [Done]
8d3b6ba4 Synchronizing projects [Done]
12638e36 Synchronizing projects [Done]
273764c0 Processing Bazel changes since last activation [Done]
181fb418 Validate documents [Done]
50aef1a8 Publish Diagnostics [Done]
79cd9327 Update classpath Job [Done]
25c5ad81 Background task [Done]
3c676bb9 Building [Done]
e7ba0c4c Building [Done]
eae1da83 Building [Done]
edb46b37 Building [Done]
4ca156b5 Building [Done]
d22b0e6d Building [Done]

The Bazel Build Status shows:

Tue 13:04:24: Reading workspace info
> bazel info

Synchronization Summary
=======================
Projects: 0
 Targets: 0
Strategy: null

Which ^^^ is clearly wrong (I think?)... would you perhaps like to add some additional logging for when it exec bazel ...?

Or perhaps I could even contibute some minor logging enhancements, some day... where in the code would this be?

I have a hunch that the "different environment" may have something to do with how Bazel / Bazelik is installed / found.

@vorburger
Copy link
Contributor Author

I have a hunch that the "different environment" may have something to do with how Bazel / Bazelik is installed / found.

For the record, mv ~/.bashrc ~/.bashrc-OFF (and mv ~/.config/fish/ ~/.config/fish-OFFalthough that hopefully shouldn't really be relevant, here) does not help.

@guw
Copy link
Collaborator

guw commented Feb 20, 2024

Is the .bazelproject file correct?

@vorburger
Copy link
Contributor Author

Is the .bazelproject file correct?

It's this one and the same on the computer where it works and the one where it does not.

Which ^^^ is clearly wrong (I think?).

For comparison, on the computer where it works it's:

Tue 19:50:28: Reading workspace info
> bazel info
Process finished in 0.122s
Loading: 0 packages loaded


Tue 19:50:29: Querying for all available packages in workspace
> bazel query --output package --keep_going --query_file /tmp/bazel_query_8947760601602725244.query.txt
Process finished in 0.104s
Loading: 0 packages loaded



Tue 19:50:29: Loading targets for 17 packages
> bazel query --output streamed_proto --order_output=no --noproto:locations --noproto:default_values --keep_going --query_file /tmp/bazel_query_1740310227718672278.query.txt
Process finished in 0.172s
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Analyzing: 2 targets (0 packages loaded, 0 targets configured)
INFO: Analyzed 2 targets (2 packages loaded, 6 targets configured).
INFO: Found 2 targets...
INFO: Elapsed time: 0.262s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions


Tue 19:50:30: Querying for Java toolchain information
> bazel cquery --output starlark --starlark:file /tmp/bazel_cquery_starlark_file_9336265339441465976.starlark.txt --query_file /tmp/bazel_cquery_1933725847932263251.query.txt
Process finished in 0.278s
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Analyzing: 67 targets (0 packages loaded, 0 targets configured)
Analyzing: 67 targets (0 packages loaded, 0 targets configured)
[0 / 1] checking cached actions
INFO: Analyzed 67 targets (1 packages loaded, 301 targets configured).
INFO: Found 67 targets...
INFO: Elapsed time: 1.068s, Critical Path: 0.05s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: 
INFO: Build Event Protocol files produced successfully.


Tue 19:50:33: Running build with IntelliJ aspects to collect classpath information
> bazel build --build_event_binary_file=/tmp/bazel_build_bep_12456281662037466346.txt --nobuild_event_binary_file_path_conversion --keep_going //common/common:src/test/java/dev/enola/common/protobuf/ProtobufMediaTypesTest //core/impl:src/test/java/dev/enola/core/tbd/RosettaTest //common/rdf:rdf //common/common:src/test/java/dev/enola/common/io/resource/FileResourceTest //common/thing:thing_java //common/thing:src/test/java/dev/enola/thing/MessageToThingConverterTest //common/common:src/test/java/dev/enola/common/io/resource/HttpUrlResourceTest //common/common:src/test/java/dev/enola/common/io/resource/NullResourceTest //core/impl:src/test/java/dev/enola/core/iri/URITemplateTest //common/common:src/test/java/dev/enola/common/io/resource/ReplacingResourceTest //common/protobuf:src/test/java/dev/enola/common/protobuf/MessagesTest //common/common:src/test/java/dev/enola/common/io/resource/ClasspathUrlResourceTest //core/impl:src/test/java/dev/enola/core/iri/URITemplateSplitterTest //core/impl:src/test/java/dev/enola/core/iri/URITemplateMatcherChainTest //common/yamljson:src/test/java/dev/enola/common/yamljson/YamlJsonTest //common/protobuf:protobuf //common/protobuf:src/test/java/dev/enola/common/protobuf/ProtoIOTest //core/impl:src/test/java/dev/enola/core/meta/TypeRepositoryTest //web/rest:rest //core/impl:src/test/java/dev/enola/core/meta/SchemaAspectTest //common/yamljson:yamljson //common/common:src/test/java/dev/enola/common/io/resource/ResourceProvidersTest //core/lib:src/test/java/dev/enola/core/IDsTest //core/impl:src/test/java/dev/enola/core/meta/EntityKindRepositoryTest //core/impl:src/test/java/dev/enola/core/meta/docgen/MarkdownDocGeneratorTest //cli:src/test/java/dev/enola/cli/EnolaLoggingTest //cli:src/test/java/dev/enola/cli/ClasspathHellDuplicatesCheckerTest //core/impl:impl //common/markdown:markdown //web/ui:ui //common/common:src/test/java/dev/enola/common/io/resource/MemoryResourceTest //core/lib:src/test/java/dev/enola/core/view/ThingsTest //common/common:src/test/java/dev/enola/common/io/mediatype/MediaTypeDetectorTest //common/rdf:src/test/java/dev/enola/rdf/ConvertersTest //core/impl:src/test/java/dev/enola/core/EntityServiceProviderTest //web/api:api //common/markdown:src/test/java/dev/enola/common/markdown/exec/RunnerTest //connectors/k8s:enola-k8s //web/ui:src/test/java/dev/enola/web/ui/UiTest //cli:src/test/java/dev/enola/cli/SystemOutErrCaptureTest //tools/hello:hello //core/impl:src/test/java/dev/enola/core/meta/TypeRegistryWrapperTest //web/sun:sun //web/sun:src/test/java/dev/enola/web/sun/test/SunServerTest //core/impl:src/test/java/dev/enola/core/meta/docgen/StringUtilTest //cli:enola //cli:src/test/java/dev/enola/cli/EnolaTest //core/lib:lib_java //common/common:src/test/java/dev/enola/common/io/mediatype/MediaTypesTest //core/impl:src/test/java/dev/enola/core/EntityTest //core/lib:src/test/java/dev/enola/core/ERITest //core/impl:src/test/java/dev/enola/core/grpc/EnolaGrpcServerTest //web/rest:src/test/java/dev/enola/web/rest/RestTest //connectors/demo:src/test/java/dev/enola/demo/ServerTest //connectors/demo:demo //common/common:src/test/java/dev/enola/common/io/resource/URIsTest //common/common:common //common/common:src/test/java/dev/enola/common/io/resource/ErrorResourceTest //common/protobuf:src/test/java/dev/enola/common/protobuf/MessageValidatorTest //core/impl:src/test/java/dev/enola/core/meta/EntityKindValidationsTest //common/markdown:src/test/java/dev/enola/common/markdown/exec/ExecMDTest //common/common:src/test/java/dev/enola/common/io/resource/MarkdownResourceTest //tools/hello:hello_lib //common/common:src/test/java/dev/enola/common/io/resource/FileDescriptorResourceTest //common/rdf:src/test/java/dev/enola/rdf/RdfTest //common/common:src/test/java/dev/enola/common/io/resource/EmptyResourceTest //common/common:src/test/java/dev/enola/common/io/resource/StringResourceTest --aspects=@@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect --aspects=@@intellij_aspect//:java_classpath.bzl%java_classpath_aspect --override_repository=intellij_aspect=/home/vorburger/.config/Code/User/workspaceStorage/5687ff7dea6a22a979f8c4dab8eb016b/redhat.java/jdt_ws/.metadata/.plugins/com.salesforce.bazel.eclipse.core/intellij-aspects/.76ff40 --output_groups=intellij-info-generic,intellij-resolve-java-direct-deps,intellij-info-java-direct-deps,runtime_classpath
Process finished in 1.1s
Reading build events... finished in 0.316s
 checking cached actions
Loading: 0 packages loaded



Tue 19:50:34: Querying for external repositories
> bazel query --output streamed_proto --order_output=no --noproto:rule_inputs_and_outputs --noproto:locations --noproto:default_values --query_file /tmp/bazel_query_12447502154645768526.query.txt
Process finished in 0.345s

Synchronization Summary
=======================
Projects: 67
 Targets: 98
Strategy: project-per-target
100.0% Synchronizing enola                                                                                          7107ms
  2.3% +- Reading workspace info                                                                                     160ms
 13.6% +- Creating workspace project                                                                                 967ms
  0.2% +- Configuring visible folders                                                                                 14ms
  5.9% +- Detecting targets                                                                                          416ms
  1.5% |  +- Querying for all available packages in workspace                                                        107ms
  3.3% |  \- Loading targets for 17 packages                                                                         234ms
 36.7% +- Provisioning Projects                                                                                     2609ms
  4.0% |  +- Querying for Java toolchain information                                                                 282ms
  0.7% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/protobu...           46ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/tbd/RosettaTest            28ms
  0.3% |  +- Provisioning Java project for target //common/rdf:rdf                                                    20ms
  0.4% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           30ms
  0.3% |  +- Provisioning Java project for target //common/thing:thing_java                                           22ms
  0.3% |  +- Provisioning Java project for target //common/thing:src/test/java/dev/enola/thing/MessageTo...           20ms
  0.5% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           36ms
  1.1% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           81ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/iri/URITempla...           28ms
  0.5% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           33ms
  0.4% |  +- Provisioning Java project for target //common/protobuf:src/test/java/dev/enola/common/proto...           26ms
  0.4% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           30ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/iri/URITempla...           26ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/iri/URITempla...           25ms
  0.3% |  +- Provisioning Java project for target //common/yamljson:src/test/java/dev/enola/common/yamlj...           19ms
  0.3% |  +- Provisioning Java project for target //common/protobuf:protobuf                                          23ms
  0.4% |  +- Provisioning Java project for target //common/protobuf:src/test/java/dev/enola/common/proto...           25ms
  1.1% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/meta/TypeRepo...           76ms
  0.4% |  +- Provisioning Java project for target //web/rest:rest                                                     25ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/meta/SchemaAs...           26ms
  0.3% |  +- Provisioning Java project for target //common/yamljson:yamljson                                          21ms
  0.3% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           23ms
  0.3% |  +- Provisioning Java project for target //core/lib:src/test/java/dev/enola/core/IDsTest                     22ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/meta/EntityKi...           27ms
  5.3% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/meta/docgen/M...          375ms
  0.3% |  +- Provisioning Java project for target //cli:src/test/java/dev/enola/cli/EnolaLoggingTest                  22ms
  0.3% |  +- Provisioning Java project for target //cli:src/test/java/dev/enola/cli/ClasspathHellDuplica...           19ms
  0.4% |  +- Provisioning Java project for target //core/impl:impl                                                    30ms
  0.3% |  +- Provisioning Java project for target //common/markdown:markdown                                          17ms
  0.2% |  +- Provisioning Java project for target //web/ui:ui                                                         17ms
  0.3% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           22ms
  0.2% |  +- Provisioning Java project for target //core/lib:src/test/java/dev/enola/core/view/ThingsTest             16ms
  1.4% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/medi...          101ms
  0.3% |  +- Provisioning Java project for target //common/rdf:src/test/java/dev/enola/rdf/ConvertersTest             18ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/EntityService...           26ms
  0.3% |  +- Provisioning Java project for target //web/api:api                                                       22ms
  0.3% |  +- Provisioning Java project for target //common/markdown:src/test/java/dev/enola/common/markd...           22ms
  0.3% |  +- Provisioning Java project for target //connectors/k8s:enola-k8s                                          22ms
  0.3% |  +- Provisioning Java project for target //web/ui:src/test/java/dev/enola/web/ui/UiTest                      18ms
  0.3% |  +- Provisioning Java project for target //cli:src/test/java/dev/enola/cli/SystemOutErrCaptureT...           20ms
  0.4% |  +- Provisioning Java project for target //tools/hello:hello                                                 25ms
  0.3% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/meta/TypeRegi...           24ms
  0.3% |  +- Provisioning Java project for target //web/sun:sun                                                       22ms
  0.4% |  +- Provisioning Java project for target //web/sun:src/test/java/dev/enola/web/sun/test/SunServ...           28ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/meta/docgen/S...           29ms
  0.3% |  +- Provisioning Java project for target //cli:enola                                                         23ms
  0.3% |  +- Provisioning Java project for target //cli:src/test/java/dev/enola/cli/EnolaTest                         21ms
  0.3% |  +- Provisioning Java project for target //core/lib:lib_java                                                 18ms
  0.3% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/medi...           24ms
  0.3% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/EntityTest                 23ms
  0.2% |  +- Provisioning Java project for target //core/lib:src/test/java/dev/enola/core/ERITest                     16ms
  1.5% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/grpc/EnolaGrp...          109ms
  0.3% |  +- Provisioning Java project for target //web/rest:src/test/java/dev/enola/web/rest/RestTest                24ms
  0.4% |  +- Provisioning Java project for target //connectors/demo:src/test/java/dev/enola/demo/ServerT...           25ms
  0.4% |  +- Provisioning Java project for target //connectors/demo:demo                                              28ms
  0.4% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           29ms
  0.5% |  +- Provisioning Java project for target //common/common:common                                              32ms
  0.4% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           27ms
  0.2% |  +- Provisioning Java project for target //common/protobuf:src/test/java/dev/enola/common/proto...           15ms
  0.4% |  +- Provisioning Java project for target //core/impl:src/test/java/dev/enola/core/meta/EntityKi...           29ms
  0.3% |  +- Provisioning Java project for target //common/markdown:src/test/java/dev/enola/common/markd...           22ms
  0.4% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           28ms
  0.4% |  +- Provisioning Java project for target //tools/hello:hello_lib                                             25ms
  0.5% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           35ms
  0.3% |  +- Provisioning Java project for target //common/rdf:src/test/java/dev/enola/rdf/RdfTest                    22ms
  0.3% |  +- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           24ms
  0.3% |  \- Provisioning Java project for target //common/common:src/test/java/dev/enola/common/io/reso...           18ms
 39.1% \- Updating classpath for workspace enola                                                                    2780ms
  0.0%    +- Computing classpath for workspace project                                                                 1ms
 36.3%    \- Computing classpath for projects using ProjectPerTargetProvisioningStrategy                            2578ms
 21.4%       +- Running build with IntelliJ aspects to collect classpath information                                1520ms
  5.1%       \- Querying for external repositories                                                                   360ms

the interesting part of all of this to compare to above is:

Synchronization Summary
=======================
Projects: 67
 Targets: 98
Strategy: project-per-target

Is the .bazelproject file correct?

I have a hunch that you have asked about this because of Strategy: project-per-target VS Strategy: null? 🤣

Where in the code does it determine that Strategy?

What could cause that to be null?

@vorburger
Copy link
Contributor Author

vorburger commented Feb 20, 2024

Hm, I just noticed that on the computer where it works I'm on VSC 1.86.2, and on the one where it doesn't I'm still on the older 1.85.1, due to ... internal work related reasons.

Let me try to double check if it reproduces with 1.86.2 on that computer...

@vorburger
Copy link
Contributor Author

vorburger commented Feb 20, 2024

Let me try to double check if it reproduces with 1.86.2 on that computer...

That doesn't seem to help.

Another difference between these 2 computers that I just found is that on the one where it works, bazel is a symlink to bazelisk, but on the one where it doesn't work it was only a shell alias. I've removed the alias now (so which bazel now shows the symlink), but it still doesn't work.

In fact, the Bazel Build Status is now even completely empty, not even showing Synchronization Summary at all, anymore. I cannot even get it to show that Synchronization Summary with the Strategy: null anymore!

So it probably fails to launch Bazel? Could we enable (or add, in code) better logging around that? Where in the code does it do that? Do you want to use (my!) https://github.com/vorburger/ch.vorburger.exec for fully logging the exec? 🤣

PS: I doubt #88 is solved. But that doesn't really matter here - whether it's launch bazel or bazelisk, if it fails to do so, it should clearly show that, and ideally perhaps print out the current PATH as well.

@vorburger
Copy link
Contributor Author

For what it's worth, in my #94 related experiments for enola-dev/enola#519 I've run into Strategy: null on GitHub Codespaces as well - but there I have always seen a java.io.IOException: Cannot run program "bazel" (in directory "/workspaces/enola"): error=2, No such file or directory (now solved).

Why on that one other computer it doesn't even show that is still a mystery to me.

@guw
Copy link
Collaborator

guw commented Feb 21, 2024

Can you check the JDTLS log file? Cmd+Shift+P > Java: Open Java Language Server Log File

@vorburger
Copy link
Contributor Author

Closing as #obsolete (it works great for me right now).

@vorburger vorburger closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants