pickling icon indicating copy to clipboard operation
pickling copied to clipboard

scalameta pickling

Open MasseGuillaume opened this issue 10 years ago • 19 comments

given https://github.com/MasseGuillaume/cats/commit/b5d25c3cd99b05b59df3ea0477d800319051285d

when sbt ";core/compile;metadocCompilerPlugin/console"

pickling fails with: fatal error: unpicklee cache is corrupted at 7

MasseGuillaume avatar Jun 23 '15 22:06 MasseGuillaume

The error message is coming from https://github.com/scala/pickling/blob/v0.10.1_2.11/core/src/main/scala/scala/pickling/internal/package.scala#L152-L161 likely some issue in structure sharing.

eed3si9n avatar Jun 23 '15 22:06 eed3si9n

@eed3si9n is right, it's an issue with structure sharing. You can try to disable structure sharing:

import scala.pickling.shareNothing._

phaller avatar Jun 24 '15 13:06 phaller

For the next pickling release we should get scalameta pickling working.

phaller avatar Jun 24 '15 13:06 phaller

@phaller If i disable structure sharing I get a stack overflow. I think this is because in the AST a node has a reference to his parent and vice versa. So there is a loop.

MasseGuillaume avatar Jun 24 '15 14:06 MasseGuillaume

@MasseGuillaume I see. Then, indeed, structure sharing is required. It would be helpful to have a smaller example that exposes this bug, though.

phaller avatar Jun 24 '15 14:06 phaller

@phaller there you go: https://github.com/MasseGuillaume/scalameta-pickling-issue

MasseGuillaume avatar Jun 29 '15 23:06 MasseGuillaume

@MasseGuillaume Great, thanks! I'll have a look at it.

phaller avatar Jul 01 '15 13:07 phaller

@MasseGuillaume I'm running into issues building the meta project (plugin builds fine):

[error] 669 errors were encountered during merge
[trace] Stack trace suppressed: run last plugin/*:assembly for the full output.
[error] (plugin/*:assembly) deduplicate: different file contents found in the following:
[error] /Users/phaller/.ivy2/cache/org.scalameta/scalahost_2.11.7/jars/scalahost_2.11.7-0.1.0-SNAPSHOT.jar:org/scalameta/adt/AdtMacros$$anon$1.class
[error] /Users/phaller/.ivy2/cache/org.scalameta/foundation_2.11/jars/foundation_2.11-0.1.0-SNAPSHOT.jar:org/scalameta/adt/AdtMacros$$anon$1.class
[error] deduplicate: different file contents found in the following:
[error] /Users/phaller/.ivy2/cache/org.scalameta/scalahost_2.11.7/jars/scalahost_2.11.7-0.1.0-SNAPSHOT.jar:org/scalameta/adt/AdtMacros$$anon$2.class
[error] /Users/phaller/.ivy2/cache/org.scalameta/foundation_2.11/jars/foundation_2.11-0.1.0-SNAPSHOT.jar:org/scalameta/adt/AdtMacros$$anon$2.class
...

Any hints how to resolve this?

phaller avatar Jul 02 '15 16:07 phaller

@xeno-by ping @phaller delete your ivy cache rm -rf ~/.ivy2/cache/org.scalameta/ and publishLocal scalameta projects in the following order:

  1. scalameta
  2. interpreter
  3. scalahost

MasseGuillaume avatar Jul 02 '15 16:07 MasseGuillaume

OK, perfect, thanks!

phaller avatar Jul 02 '15 16:07 phaller

@MasseGuillaume should work now, but I really have no clue how to fix it in the long run unless sbt changes the way they handle compiler plugins.

xeno-by avatar Jul 03 '15 09:07 xeno-by

@MasseGuillaume I can build and run the compiler plugin now, but I couldn't reproduce the bug, yet, unfortunately. I'll keep looking.

phaller avatar Jul 03 '15 15:07 phaller

@phaller if you need help we can do a Google Hangout. You can send and chat invite to [email protected].

MasseGuillaume avatar Jul 03 '15 15:07 MasseGuillaume

@MasseGuillaume OK, sounds good!

phaller avatar Jul 03 '15 15:07 phaller

meta/test

MasseGuillaume avatar Jul 03 '15 15:07 MasseGuillaume

@phaller any updates ?

MasseGuillaume avatar Jul 17 '15 18:07 MasseGuillaume

@MasseGuillaume sorry, I had to context-switch to other things. However, I found out that it was trying to use the runtime pickler/unpickler which caused issues. I think we need to try to have picklers generated systematically for all involved classes. If picklers cannot be generated via the Pickler.generate macro, try custom picklers.

phaller avatar Jul 22 '15 18:07 phaller

@MasseGuillaume I just finsihed a custom pickler tutorial, if you need: https://github.com/scala/pickling/wiki/Writing-custom-Picklers-Unpicklers

Let me know if you need any help getting scala-meta compiled using picklers.

jsuereth avatar Aug 09 '15 19:08 jsuereth

@jsuereth thanks I will try this approach ;-)

MasseGuillaume avatar Aug 09 '15 22:08 MasseGuillaume