google / closure-compiler

A JavaScript checker and optimizer.
https://developers.google.com/closure/compiler/
Apache License 2.0
7.41k stars 1.15k forks source link

Unable to build from source #4170

Closed vobruba-martin closed 5 months ago

vobruba-martin commented 5 months ago

Since yesterday I'm not able to build Closure compiler from source. Am I doing something wrong?

$ git clone https://github.com/google/closure-compiler.git
Cloning into 'closure-compiler'...
$ cd closure-compiler
$ git show --oneline -s
6ec2e3995 Add mechanism for js_library typechecking to inject runtime libraries
$ bazel-5.1.1 clean
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
$ bazel-5.1.1 build --jobs=3 //:compiler_uberjar_deploy.jar
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 1 packages loaded
Analyzing: target //:compiler_uberjar_deploy.jar (1 packages loaded, 0 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (34 packages loaded, 138 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (50 packages loaded, 777 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (50 packages loaded, 777 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (50 packages loaded, 777 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (50 packages loaded, 777 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (53 packages loaded, 939 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (54 packages loaded, 1745 targets configured)
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/auto/value/auto-value-annotations/1.10.4/auto-value-annotations-1.10.4.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/auto/value/auto-value/1.10.4/auto-value-1.10.4.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/auto/service/auto-service-annotations/1.1.1/auto-service-annotations-1.1.1.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/auto/auto-common/1.2.2/auto-common-1.2.2.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/guava/guava/33.0.0-jre/guava-33.0.0-jre.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/auto/service/auto-service/1.1.1/auto-service-1.1.1.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/guava/guava-beta-checker/1.0/guava-beta-checker-1.0.jar failed: class java.io.FileNotFoundException GET returned 404 Not Found
Analyzing: target //:compiler_uberjar_deploy.jar (82 packages loaded, 1909 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (82 packages loaded, 1909 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (83 packages loaded, 2029 targets configured)
Analyzing: target //:compiler_uberjar_deploy.jar (83 packages loaded, 2029 targets configured)
INFO: Analyzed target //:compiler_uberjar_deploy.jar (84 packages loaded, 2246 targets configured).
INFO: Found 1 target...
[0 / 7] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[34 / 126] JavaToolchainCompileBootClasspath external/rules_java/toolchains/platformclasspath.jar; 2s local ... (2 actions running)
[42 / 126] Building external/rules_jvm_external/private/tools/java/com/github/bazelbuild/rules_jvm_external/zip/libzip.jar (1 source file); 2s local ... (3 actions running)
[46 / 126] Building src/com/google/javascript/jscomp/conformance/libconformance_proto-speed.jar (1 source jar); 5s local ... (3 actions running)
[85 / 126] Creating compile jar for @maven//:com_google_guava_guava; 0s local ... (3 actions running)
[107 / 126] Building src/com/google/javascript/rhino/typed_ast/libtyped_ast_proto-speed.jar (1 source jar); 6s local ... (3 actions running)
[110 / 126] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 15s local ... (3 actions running)
[112 / 126] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 26s local ... (3 actions running)
[116 / 126] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 40s local ... (3 actions running)
[118 / 126] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 55s local ... (2 actions running)
INFO: From Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor):
warning: [options] system modules path not set in conjunction with -source 11
[120 / 126] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 45s local ... (2 actions running)
ERROR: /builds/mybuild/closure-compiler/BUILD.bazel:157:9: TypedAST runtime_libs.typedast.gz failed: (Exit 3): compiler_unshaded_no_runtime_libs failed: error executing command bazel-out/k8-opt-exec-2B5CBBC6/bin/compiler_unshaded_no_runtime_libs --checks_only --strict_mode_input '--env=CUSTOM' '--language_out=ES_NEXT' '--inject_libraries=false' '--jscomp_error=checkTypes' ... (remaining 145 arguments skipped)
src/com/google/javascript/jscomp/js/es6/asynccontext/snapshot.js:31:29: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type AsyncContext.Snapshot
  31|   /** @constructor @extends {AsyncContext.Snapshot} */
                                   ^
src/com/google/javascript/jscomp/js/es6/asynccontext/variable.js:102:15: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type AsyncContext.Variable
  102|    * @extends {AsyncContext.Variable}
                      ^
src/com/google/javascript/jscomp/js/es6/asynccontext/variable.js:369:28: ERROR - [JSC_POSSIBLE_INEXISTENT_PROPERTY] Property handleEvent never defined on listener
This property is accessed on a "loose" type, but is not defined anywhere in the program, so it must not exist.
  369|             return listener.handleEvent.apply(listener, arguments);
                                   ^^^^^^^^^^^
3 error(s), 0 warning(s), 93.7224295894% typed
Target //:compiler_uberjar_deploy.jar failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 134.896s, Critical Path: 85.99s
INFO: 122 processes: 15 internal, 107 local.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
ERROR: Job failed: exit code 1
lauraharker commented 5 months ago

Hi, sorry for the breakage - I'm looking into this & should be able to fix it today. We will probably stop open-sourcing src/com/google/javascript/jscomp/js/es6/asynccontext as it's not ready for general usage yet.

lauraharker commented 5 months ago

Oops, https://github.com/google/closure-compiler/commit/827e3b208b085ff3d790a7521889ae354cf3c863 fixed the build but now actually running the compiler fails to load the polyfills.txt resource. I have a followup change to fix it - just modifying https://github.com/google/closure-compiler/commit/827e3b208b085ff3d790a7521889ae354cf3c863#diff-7fc57714ef13c3325ce2a1130202edced92fcccc0c6db34a72f7b57f60d552a3 to generate it at src/java/com/google/javascript/jscomp/js/polyfills.txt.

lauraharker commented 5 months ago

Fixed by https://github.com/google/closure-compiler/commit/8d037f6e1fad9a707b7e839d8e42867b3a44568f

Successful build: https://github.com/google/closure-compiler/actions/runs/9666739515/job/26666946731

vobruba-martin commented 4 months ago

On top of that I had to install nodejs to make the build process working again. Thank you!

ltlly commented 4 months ago

It seems that the content related to polyfills.txt has not been fixed. I use


bazel run //:compiler_unshaded_no_runtime_libs -- --js="/data/workspace/closure-compiler/tmp/nmsl.js" --js_output_file=output.min.js
Loading: 
Loading: 0 packages loaded
Analyzing: target //:compiler_unshaded_no_runtime_libs (1 packages loaded, 0 targets configured)
INFO: Analyzed target //:compiler_unshaded_no_runtime_libs (84 packages loaded, 2058 targets configured).
INFO: Found 1 target...
[0 / 1] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[20 / 67] JavaToolchainCompileBootClasspath external/rules_java/toolchains/platformclasspath.jar; 0s local ... (2 actions running)
[21 / 67] JavaToolchainCompileBootClasspath external/rules_java/toolchains/platformclasspath.jar; 1s local ... (2 actions, 1 running)
[23 / 67] Building src/com/google/javascript/rhino/typed_ast/libtyped_ast_proto-speed.jar (1 source jar); 1s local ... (13 actions, 12 running)
[30 / 67] Building src/com/google/javascript/rhino/typed_ast/libtyped_ast_proto-speed.jar (1 source jar); 2s local ... (7 actions running)
[33 / 67] Building src/com/google/javascript/rhino/typed_ast/libtyped_ast_proto-speed.jar (1 source jar); 6s local ... (4 actions running)
[46 / 67] Building src/com/google/javascript/rhino/typed_ast/libtyped_ast_proto-speed.jar (1 source jar); 8s local ... (16 actions running)
[64 / 67] Building src/com/google/javascript/rhino/typed_ast/libtyped_ast_proto-speed.jar (1 source jar); 9s local ... (2 actions running)
[65 / 67] Building libcompiler_lib_no_runtime_libs-class.jar (784 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 4s local
[65 / 67] Building libcompiler_lib_no_runtime_libs-class.jar (784 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 12s local
INFO: From Building libcompiler_lib_no_runtime_libs-class.jar (784 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor):
warning: [options] system modules path not set in conjunction with -source 11
[66 / 67] [Prepa] Building Java resource jar
Target //:compiler_unshaded_no_runtime_libs up-to-date:
  bazel-bin/compiler_unshaded_no_runtime_libs.jar
  bazel-bin/compiler_unshaded_no_runtime_libs
INFO: Elapsed time: 40.869s, Critical Path: 39.96s
INFO: 67 processes: 8 internal, 59 local.
INFO: Build completed successfully, 67 total actions
INFO: Running command line: bazel-bin/compiler_unshaded_no_runtime_libs '--js=/data/workspace/closure-compiler/tmp/nmsl.js' '--js_output_file=output.min.js'
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 67 total actions
INFO: Build completed successfully, 67 total actions
java.lang.RuntimeException: No such resource: js/polyfills.txt
    at com.google.javascript.jscomp.resources.ResourceLoader.loadTextResource(ResourceLoader.java:38)
    at com.google.javascript.jscomp.RewritePolyfills.<init>(RewritePolyfills.java:68)
    at com.google.javascript.jscomp.TranspilationPasses.lambda$static$2(TranspilationPasses.java:374)
    at com.google.javascript.jscomp.PassFactory.create(PassFactory.java:90)
    at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:240)
    at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:179)
    at com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations(Compiler.java:2968)
    at com.google.javascript.jscomp.Compiler.lambda$stage2Passes$7(Compiler.java:1025)
    at com.google.javascript.jscomp.CompilerExecutor.lambda$runInCompilerThread$0(CompilerExecutor.java:100)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
lauraharker commented 4 months ago

@vobruba-martin I'll note in the README that Node is now required to build from source, thanks for pointing that out.

@ltlly why are you using //:compiler_unshaded_no_runtime_libs? It's intended for a specific step in our build process that builds the runtime library, but not for general use.

I see the same crash synced to a commit from a month ago https://github.com/google/closure-compiler/commit/5af748442b266a8e4331cfd4213cda39596e1b79. I believe this is WAI.

ltlly commented 4 months ago

@vobruba-martin I'll note in the README that Node is now required to build from source, thanks for pointing that out.

@ltlly why are you using //:compiler_unshaded_no_runtime_libs? It's intended for a specific step in our build process that builds the runtime library, but not for general use.

I see the same crash synced to a commit from a month ago 5af7484. I believe this is WAI.

In the README, I saw this. image

So I used IDEA and the Bazel plugin. When I clicked run, it automatically executed the following command for me. What is the correct way to build CommandLineRunner from IDEA? Do Eclipse and IDEA behave differently when running a class?

/usr/bin/setsid --wait bazel run --tool_tag=ijwb:IDEA:ultimate --override_repository=intellij_aspect=/root/.local/share/JetBrains/IntelliJIdea2024.1/ijwb/aspect --curses=no --color=yes --progress_in_terminal_title=no --build_event_binary_file=/tmp/intellij-bep-87d9de58-39e7-4b81-8542-2b3d5f319240 --nobuild_event_binary_file_path_conversion -- //:compiler_unshaded_no_runtime_libs --js=/data/workspace/closure-compiler/tmp/nmsl.js --js_output_file=output.min.js
Loading: 
Loading: 0 packages loaded
Analyzing: target //:compiler_unshaded_no_runtime_libs (0 packages loaded, 0 targets configured)
INFO: Analyzed target //:compiler_unshaded_no_runtime_libs (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[1 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[9 / 12] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 1s local
[9 / 12] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 11s local
INFO: From Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor):
warning: [options] system modules path not set in conjunction with -source 11
[10 / 12] [Prepa] Building Java resource jar
Target //:compiler_unshaded_no_runtime_libs up-to-date:
  bazel-bin/compiler_unshaded_no_runtime_libs.jar
  bazel-bin/compiler_unshaded_no_runtime_libs
INFO: Elapsed time: 27.219s, Critical Path: 26.99s
INFO: 3 processes: 1 internal, 2 local.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: bazel-bin/compiler_unshaded_no_runtime_libs '--js=/data/workspace/closure-compiler/tmp/nmsl.js' '--js_output_file=output.min.js'
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 3 total actions
INFO: Build completed successfully, 3 total actions
java.lang.RuntimeException: No such resource: js/polyfills.txt
    at com.google.javascript.jscomp.resources.ResourceLoader.loadTextResource(ResourceLoader.java:37)
    at com.google.javascript.jscomp.RewritePolyfills.<init>(RewritePolyfills.java:68)
    at com.google.javascript.jscomp.TranspilationPasses.lambda$static$2(TranspilationPasses.java:387)
    at com.google.javascript.jscomp.PassFactory.create(PassFactory.java:90)
    at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:240)
    at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:179)
    at com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations(Compiler.java:3017)
    at com.google.javascript.jscomp.Compiler.lambda$stage2Passes$7(Compiler.java:1059)
    at com.google.javascript.jscomp.CompilerExecutor.lambda$runInCompilerThread$0(CompilerExecutor.java:100)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
ltlly commented 4 months ago

@vobruba-martin I'll note in the README that Node is now required to build from source, thanks for pointing that out. @ltlly why are you using //:compiler_unshaded_no_runtime_libs? It's intended for a specific step in our build process that builds the runtime library, but not for general use. I see the same crash synced to a commit from a month ago 5af7484. I believe this is WAI.

In the README, I saw this. image

So I used IDEA and the Bazel plugin. When I clicked run, it automatically executed the following command for me. What is the correct way to build CommandLineRunner from IDEA? Do Eclipse and IDEA behave differently when running a class?

/usr/bin/setsid --wait bazel run --tool_tag=ijwb:IDEA:ultimate --override_repository=intellij_aspect=/root/.local/share/JetBrains/IntelliJIdea2024.1/ijwb/aspect --curses=no --color=yes --progress_in_terminal_title=no --build_event_binary_file=/tmp/intellij-bep-87d9de58-39e7-4b81-8542-2b3d5f319240 --nobuild_event_binary_file_path_conversion -- //:compiler_unshaded_no_runtime_libs --js=/data/workspace/closure-compiler/tmp/nmsl.js --js_output_file=output.min.js
Loading: 
Loading: 0 packages loaded
Analyzing: target //:compiler_unshaded_no_runtime_libs (0 packages loaded, 0 targets configured)
INFO: Analyzed target //:compiler_unshaded_no_runtime_libs (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[1 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[9 / 12] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 1s local
[9 / 12] Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor); 11s local
INFO: From Building libcompiler_lib_no_runtime_libs-class.jar (785 source files) and running annotation processors (AutoAnnotationProcessor, AutoOneOfProcessor, AutoValueProcessor):
warning: [options] system modules path not set in conjunction with -source 11
[10 / 12] [Prepa] Building Java resource jar
Target //:compiler_unshaded_no_runtime_libs up-to-date:
  bazel-bin/compiler_unshaded_no_runtime_libs.jar
  bazel-bin/compiler_unshaded_no_runtime_libs
INFO: Elapsed time: 27.219s, Critical Path: 26.99s
INFO: 3 processes: 1 internal, 2 local.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: bazel-bin/compiler_unshaded_no_runtime_libs '--js=/data/workspace/closure-compiler/tmp/nmsl.js' '--js_output_file=output.min.js'
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 3 total actions
INFO: Build completed successfully, 3 total actions
java.lang.RuntimeException: No such resource: js/polyfills.txt
  at com.google.javascript.jscomp.resources.ResourceLoader.loadTextResource(ResourceLoader.java:37)
  at com.google.javascript.jscomp.RewritePolyfills.<init>(RewritePolyfills.java:68)
  at com.google.javascript.jscomp.TranspilationPasses.lambda$static$2(TranspilationPasses.java:387)
  at com.google.javascript.jscomp.PassFactory.create(PassFactory.java:90)
  at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:240)
  at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:179)
  at com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations(Compiler.java:3017)
  at com.google.javascript.jscomp.Compiler.lambda$stage2Passes$7(Compiler.java:1059)
  at com.google.javascript.jscomp.CompilerExecutor.lambda$runInCompilerThread$0(CompilerExecutor.java:100)
  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  at java.base/java.lang.Thread.run(Thread.java:840)

Apologies for the confusion. I realized the issue was due to clicking "run" in front of the class, which detected an incorrect target. The correct approach is to click "run" in front of compiler_uberjar in the BUILD.bazel file. This resolves the issue and ensures that the debug functionality in IntelliJ IDEA works as expected. Sorry for any inconvenience caused and thank you for your understanding.I am a beginner with Bazel

This is true

image