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

"could not find Lazy implicit value" on incremental compile #38

Open
akitaylor opened this issue Aug 12, 2016 · 17 comments
Open

"could not find Lazy implicit value" on incremental compile #38

akitaylor opened this issue Aug 12, 2016 · 17 comments

Comments

@akitaylor
Copy link

Hi!

I'm facing a strange problem, namely the following problem occures sometimes on inctremental build, but usually a full rebuild solves it:

[error] D:\projektek\Beelend\hg\beelend\app\models\events\EventLogType.scala:174: could not find Lazy implicit value of type julienrf.json.derived.DerivedReads[models.events.EventInfo]
[error]   implicit val fmtLogItemRead: Reads[EventInfo] = derived.reads[EventInfo].orElse(Reads.pure(UnknownEventInfo()))
[error]                                                                ^
[error] D:\projektek\Beelend\hg\beelend\app\models\events\EventLogType.scala:175: possible missing interpolator: detected an interpolated expression
[error]   implicit val fmtLogItemWrite: OWrites[EventInfo] = derived.owrites[EventInfo]

Anyway thanks for the great library.

Regards,
Akos

@julienrf
Copy link
Owner

Hi, thanks for reporting. I think this is more a problem of the way the incremental build works, though…

@akitaylor
Copy link
Author

Hi, as I experienced lately, the problem also occures in full rebuilds, but after 2 or 3 tries usually succeeds to build it. Is there some kind of nondeterministic algorithm in the build process?
Is there a way I can debug the build process or acquire debug information about the problem?

@julienrf
Copy link
Owner

julienrf commented Sep 1, 2016

According to this discussion with Miles: https://gitter.im/milessabin/shapeless?at=57c7f646d52261ec34463b0a
Could you try with typelevel/scala and report any improvement here?

@akitaylor
Copy link
Author

Thanks, I have tried the typelevel scala compiler.
When running the Play allpication in Intellij the same happens:

[info] Compiling 204 Scala sources and 2 Java sources to D:\projektek\Beelend\hg\beelend\target\scala-2.11\classes...
[error] D:\projektek\Beelend\hg\beelend\app\models\events\EventLogType.scala:177: could not find Lazy implicit value of type julienrf.json.derived.DerivedReads[models.events.EventInfo]
[error]   implicit val fmtLogItemRead: Reads[EventInfo] = derived.reads[EventInfo].orElse(Reads.pure(UnknownEventInfo()))
[error]                                                                ^
[error] D:\projektek\Beelend\hg\beelend\app\models\events\EventLogType.scala:178: possible missing interpolator: detected an interpolated expression
[error]   implicit val fmtLogItemWrite: OWrites[EventInfo] = derived.owrites[EventInfo]
[error]                ^
[error] D:\projektek\Beelend\hg\beelend\app\models\events\EventLogType.scala:178: could not find Lazy implicit value of type julienrf.json.derived.DerivedOWrites[models.events.EventInfo]
[error]   implicit val fmtLogItemWrite: OWrites[EventInfo] = derived.owrites[EventInfo]
[error]                                                                     ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed

Compilation in activator seems to work, at least I could not reproduce the problem.

@julienrf
Copy link
Owner

julienrf commented Sep 1, 2016

Do you also have the problem when you compile from activator without using typelevel/scala?

@akitaylor
Copy link
Author

Well, I tried to compile with activator on a linux machine and the problem also occures with typelevel compiler:

[beelend] $ compile
[info] Updating {file:/home/beelend/hg/beelend/}beelend...
[info] Resolving jline#jline;2.12.1 ...
[info] downloading https://repo1.maven.org/maven2/org/typelevel/scala-library/2.11.8/scala-library-2.11.8.jar ...
[info]  [SUCCESSFUL ] org.typelevel#scala-library;2.11.8!scala-library.jar (436ms)
[info] downloading https://repo1.maven.org/maven2/org/typelevel/scala-reflect/2.11.8/scala-reflect-2.11.8.jar ...
[info]  [SUCCESSFUL ] org.typelevel#scala-reflect;2.11.8!scala-reflect.jar (297ms)
[info] downloading https://repo1.maven.org/maven2/org/typelevel/scala-compiler/2.11.8/scala-compiler-2.11.8.jar ...
[info]  [SUCCESSFUL ] org.typelevel#scala-compiler;2.11.8!scala-compiler.jar (952ms)
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn]  * org.webjars:jquery:(2.1.4, [1.9.1,), 1.11.1) -> 2.2.1
[warn]  * org.webjars:bootstrap:(3.3.5, 3.2.0, 3.0.3, 2.3.0, 3.0.0) -> 3.3.6
[warn] Run 'evicted' to see detailed eviction warnings
[info] Compiling 204 Scala sources and 2 Java sources to /home/beelend/hg/beelend/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.8. Compiling...
[info]   Compilation completed in 16.51 s
[error] /home/beelend/hg/beelend/app/models/events/EventLogType.scala:177: could not find Lazy implicit value of type julienrf.json.derived.DerivedReads[models.events.EventInfo]
[error]   implicit val fmtLogItemRead: Reads[EventInfo] = derived.reads[EventInfo].orElse(Reads.pure(UnknownEventInfo()))
[error]                                                                ^
[error] /home/beelend/hg/beelend/app/models/events/EventLogType.scala:178: possible missing interpolator: detected an interpolated expression
[error]   implicit val fmtLogItemWrite: OWrites[EventInfo] = derived.owrites[EventInfo]
[error]                ^
[error] /home/beelend/hg/beelend/app/models/events/EventLogType.scala:178: could not find Lazy implicit value of type julienrf.json.derived.DerivedOWrites[models.events.EventInfo]
[error]   implicit val fmtLogItemWrite: OWrites[EventInfo] = derived.owrites[EventInfo]
[error]                                                                     ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 88 s, completed Sep 1, 2016 1:28:03 PM

@julienrf
Copy link
Owner

julienrf commented Sep 1, 2016

Can you share a minimal test case that reproduces the problem?

@matthull
Copy link

I'm running into what seems to be the same issue even after switching to the typelevel compiler. Going to try to create a simple standalone repo that reproduces the issue and if I'm successful will post a link to it here.

@akitaylor
Copy link
Author

I would be grateful if you could make a test case. I tried to isolate the problem, but unfortunately the problem disappeared when I made the application simpler. I suspect that the problem is related to the complexity of other codes that might influence the order/mode of compilation of the Json macros.

Some additional info in my case: I use play Json formatter and the derived codecs mixed, and the case classes (that are converted to Json) are spread in multiple source files. Usually two or three tries of compiling make the problem go away.

@matthull
Copy link

@akitaylor I stopped getting this error when I completely eliminated Play Json.format in favor of derived.oformat. Mind you I don't consistently see an issue when mixing format and oformat but getting rid of format seemed to do the trick (so far.)

And now I'm having trouble reproducing the issue even when I start incrementally reverting from format to oformat...

@yarondav
Copy link

Hi,

Anyone had any luck solving this issue?
We're also running into this with v4.0.0 version alongside Play 2.6.x.

Thanks!

@akitaylor
Copy link
Author

akitaylor commented Feb 20, 2018 via email

@WayneWang12
Copy link

Strange issue. Just get across to it. I'll see what I can do for it.

@WayneWang12
Copy link

I found that sealed is required. Otherwise this error will occur. I think it's better to elaborate this on the document.

@WayneWang12
Copy link

And also remember to put every sealed trait to seperate files. Otherwise there may be errors like java.util.NoSuchElementException: value inst$macro$2, especially when you are using this library in a scala.js project.

@akitaylor
Copy link
Author

Hi Wayne! Thanks for the investigation. In our system the attached file is the trigger of the problem. As you can see we use sealed abstract classes and case classes inherit these. It is strange that the problem only occurs after SBT clean, the second compilation is usually successful. It is also an important circumstance, that the project contains 200+ scala classes, it might not show up in smaller projects.

Here is what we get:
[warn] Run 'evicted' to see detailed eviction warnings
[info] Compiling 231 Scala sources and 3 Java sources to D:\myproject\hg\myproject\target\scala-2.11\classes...
[warn] D:\myproject\hg\myproject\app\models\events\EventLogType.scala:207: possible missing interpolator: detected an interpolated expression
[warn] implicit val fmtLogItemWrite: OWrites[EventInfo] = derived.owrites[EventInfo]
[warn] ^
[error] D:\myproject\hg\myproject\app\models\events\EventLogType.scala:207: could not find Lazy implicit value of type julienrf.json.derived.DerivedOWrites[models.events.EventInfo]
[error] implicit val fmtLogItemWrite: OWrites[EventInfo] = derived.owrites[EventInfo]
[error] ^
[error] D:\myproject\hg\myproject\app\models\events\EventLogType.scala:213: could not find Lazy implicit value of type julienrf.json.derived.DerivedReads[models.events.EventInfo]
[error] implicit val fmtLogItemRead: Reads[EventInfo] = derived.reads[EventInfo].orElse(Reads.pure(UnknownEventInfo()))
[error] ^
[warn] one warning found
[error] two errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 106 s, completed 2018.04.18. 8:09:52

EventLogType.zip

@WayneWang12
Copy link

I'm not sure. But firstly you can try seperating each sealed trait or class to their own files, i.e. not in one file.

Secondly you can try to make every implicit val formatter = oformt[A]() to implicit lazy val formatter = ...

And also the sequence of trait and object matters.

My problem is solved. But I don't have enough case classes to do the test.

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

5 participants