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

Error when trying to load rules_twirl. #32

Closed
Srikrishna31 opened this issue Sep 28, 2020 · 7 comments
Closed

Error when trying to load rules_twirl. #32

Srikrishna31 opened this issue Sep 28, 2020 · 7 comments

Comments

@Srikrishna31
Copy link

Thanks for writing a wrapper for twirl template compiler. I'm trying to use it in my project, and with the changes as suggested in the readme.md, I see the following error:

INFO: Call stack for the definition of repository 'twirl' which is a pinned_coursier_fetch (rule definition at D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/coursier.bzl:927:25):
 - D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/defs.bzl:126:9
 - D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/defs.bzl:126:9
 - D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/io_bazel_rules_twirl/workspace.bzl:8:5
 - D:/github_projects/scala_play/WORKSPACE:39:1
ERROR: An error occurred during the fetch of repository 'twirl':
   Traceback (most recent call last):
        File "D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/coursier.bzl", line 375
                parser.generate_imports(<6 more arguments>)
        File "D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/private/dependency_tree_parser.bzl", line 180, in parser.generate_imports
                artifact["directDependencies"]
key "directDependencies" not found in dictionary
ERROR: no such package '@twirl//': Traceback (most recent call last):
        File "D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/coursier.bzl", line 375
                parser.generate_imports(<6 more arguments>)
        File "D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/private/dependency_tree_parser.bzl", line 180, in parser.generate_imports
                artifact["directDependencies"]
key "directDependencies" not found in dictionary
ERROR: no such package '@twirl//': Traceback (most recent call last):
        File "D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/coursier.bzl", line 375
                parser.generate_imports(<6 more arguments>)
        File "D:/cygwin64/home/coolk/_bazel_coolk/5hvenqa4/external/rules_jvm_external/private/dependency_tree_parser.bzl", line 180, in parser.generate_imports
                artifact["directDependencies"]
key "directDependencies" not found in dictionary
INFO: Elapsed time: 1.218s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

Am I missing something? I see the same error in Linux as well.

Thanks,
Krishna

@SrodriguezO
Copy link
Contributor

Hi Krishna,

Are you invoking twirl_repositories() from your WORKSPACE after loading it?

Could you please share a minimal reproducible example so we can help you troubleshoot more effectively? Also, which version of Bazel are you using?

Thanks,
Sergio

@Srikrishna31
Copy link
Author

Hello Sergio,
Thank you for your response. My repository is open in github. Here is the link to the PR: Srikrishna31/scala_play#9 - If you look in the workspace file, I commented out the rules_twirl part, since that was creating issues for me. I'm using bazel version 3.1.0.

Let me know if the project link I provided is sufficient, or you still want a more minimal example.

Thanks,
Krishna

@SrodriguezO
Copy link
Contributor

Hey Krishna,

It looks like you're using a rather old version of rules_twirl; updating to the latest version fixes the issue. Could you please try updating to the latest version?

rules_twirl_version = "9ac789845e3a481fe520af57bd47a4261edb684f"
sha256 = "b1698a2a59b76dc9df233314c2a1ca8cee4a0477665cff5eafd36f92057b2044"

I'll update the readme to stop recommending such an old commit.

Please let me know if you run into other issues.

-Sergio

@SrodriguezO
Copy link
Contributor

@Srikrishna31 I'm closing this issue since updating the version should do the trick; please let me know if you run into any other issues :)

@Srikrishna31
Copy link
Author

Srikrishna31 commented Nov 24, 2020 via email

@Srikrishna31
Copy link
Author

Srikrishna31 commented Nov 26, 2020

Hi Sergio, The new version poses a new problem. Below is the output that I see with the new version:

bazel build :App
INFO: Analyzed target //:App (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/l-8296/github_projects/scala_play/app/BUILD:40:1: Compiling twirl template failed (Exit 1): compiler-cli failed: error executing command 
  (cd /home/l-8296/.cache/bazel/_bazel_l-8296/76d33ba2f8986abe556e65dc46b40a5c/execroot/__main__ && \
  exec env - \
  bazel-out/host/bin/external/io_bazel_rules_twirl/compiler-cli/compiler-cli @bazel-out/k8-fastbuild/bin/app/gen/twirl-templates/app/src/main/scala/views/main.html.scala-0.params)
Execution platform: @local_config_platform//:host
java.lang.NullPointerException
        at play.twirl.compiler.TwirlCompiler$.source2TemplateName(TwirlCompiler.scala:245)
        at play.twirl.compiler.TwirlCompiler$.generatedFileVirtual(TwirlCompiler.scala:229)
        at play.twirl.compiler.TwirlCompiler$.compileVirtual(TwirlCompiler.scala:185)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler$.work(CommandLineTwirlTemplateCompiler.scala:64)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler$.work(CommandLineTwirlTemplateCompiler.scala:9)
        at higherkindness.rules_scala.common.worker.WorkerMain.process$1(WorkerMain.scala:53)
        at higherkindness.rules_scala.common.worker.WorkerMain.main(WorkerMain.scala:73)
        at higherkindness.rules_scala.common.worker.WorkerMain.main$(WorkerMain.scala:22)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler$.main(CommandLineTwirlTemplateCompiler.scala:9)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler.main(CommandLineTwirlTemplateCompiler.scala)
Target //:App failed to build
INFO: Elapsed time: 10.974s, Critical Path: 10.29s
INFO: 15 processes: 14 linux-sandbox, 1 worker.
FAILED: Build did NOT complete successfully

My index.scala.html and main.scala.html are very simple files. main.scala.html doesn't take any parameters, and that might be causing a NullPointerException?
It's the same PR: Srikrishna31/scala_play#9
Thanks,
Krishna Addepalli

@SrodriguezO
Copy link
Contributor

Apologies for the delay; I responded on your follow up issue

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