pickling icon indicating copy to clipboard operation
pickling copied to clipboard

IOException on compilation (filename too long).

Open Synesso opened this issue 11 years ago • 18 comments

The following is fine:

  case class X(ys: List[Int])
  println(X(List(1,2,3)).pickle)

  case class X2345(ys: List[Int])
  println(X2345(List(1,2,3)).pickle)

When I add this line, I get a 658-line long compile-time exception:

  case class X2345678(ys: List[Int])
  println(X2345678(List(1,2,3)).pickle)

error log: https://gist.github.com/Synesso/e2d39de5be20e7f302be

Synesso avatar Aug 01 '13 13:08 Synesso

I am facing this issue as well. Compiler crashes.

import scala.pickling._
import binary._

object Enclose {
  case class Test1(s: String, t: List[(String, Test2)])
  case class Test2(s: String, i: Int, o: Option[String])
}


object Application extends App {
import Enclose._
    val pl = Test1("some string", List(("some string", Test2("some string", 23, Some("some string"))))).pickle
    println(pl)
    println(pl.unpickle[Test1])
}

uncaught exception during compilation: java.io.IOException File name too long

Error log: http://pastebin.com/rB87zrb4

eklavya avatar Sep 19 '13 11:09 eklavya

Thanks for the reports. This is on our shortlist, will try to get to the bottom of it shortly :)

Thanks for your patience!

heathermiller avatar Sep 19 '13 11:09 heathermiller

I ran across this bug report while trying to figure out a similar problem (on a different Scala project).

In case it helps, this mail is reporting similar failures when compiling inside an Ubuntu encrypted home directory. Not sure if it's the problem here but thought I'd drop in a comment.

futurechimp avatar Oct 13 '13 09:10 futurechimp

I'm getting the same compiler error: ...some big tree... [error] uncaught exception during compilation: java.io.IOException [error] File name too long [error] two errors found

I tried to set -Xmax-classfile-name to 255, the max value, (must be in range 72 to 255 inclusive). The weird thing is, if you set the max size to 72 <= size <= 254, it works. 255 breaks it.

yashton avatar Oct 29 '13 18:10 yashton

So the workaround is adding this to build.sbt:

scalacOptions ++= Seq("-Xmax-classfile-name", "254")

scala-pickling seems to generate so insanely long filenames that it's almost scary. I think there should be fair warning about this on the documentation, because if you use real package names instead of just toying around, you hit the problem pretty much instantly.

hoxu avatar Dec 29 '13 14:12 hoxu

This problem really occurs on encrypted home folders in Ubuntu. I solved the problem by creating another folder /home/unencrypted and copied my project there.

axaluss avatar Jan 17 '14 04:01 axaluss

Same here, this problem occurs when I do it in my encrypted home directory, doesn't elsewhere.

nietaki avatar Jan 19 '14 17:01 nietaki

I have the same issue but my drive is not encrypted. I've tried moving my project out of my /home folder (even moved it on to a usb stick to be certain it wasn't encrypted) and still get the issue!

I have a Play! project that uses pickle. I added: val defaultScalacOptions = Seq("-Xmax-classfile-name", "254")

to Build.scala but made no difference! I'm stuck, any ideas?

glidester avatar Jan 28 '14 10:01 glidester

Ok. This is very odd.

On the play! command line if I run 'clean' then 'compile' I get:

[info] Compiling 12 Scala sources and 2 Java sources to /home/tim/az/securesocial/samples/scala/demo/target/scala-2.10/classes...
[error] 
[error]      while compiling: /home/tim/az/securesocial/samples/scala/demo/target/scala-2.10/src_managed/main/views/html/main.template.scala
[error]         during phase: jvm
[error]      library version: version 2.10.2
[error]     compiler version: version 2.10.2
[error]   reconstructed args: -encoding utf8 -deprecation -classpath /home/tim/az/securesocial/samples/scala/demo/target/scala-2.10/classes:/home/tim/az/securesocial/samples/scala/demo/lib/scala-pickling_2.10-0.8.0-SNAPSHOT.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/play_2.10/2.2.1/jars/play_2.10.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/sbt-link/2.2.1/jars/sbt-link.jar:/opt/play-2.2.1/repository/local/org.javassist/javassist/3.18.0-GA/bundles/javassist.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/play-exceptions/2.2.1/jars/play-exceptions.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/templates_2.10/2.2.1/jars/templates_2.10.jar:/opt/play-2.2.1/repository/local/com.github.scala-incubator.io/scala-io-file_2.10/0.4.2/jars/scala-io-file_2.10.jar:/opt/play-2.2.1/repository/local/com.github.scala-incubator.io/scala-io-core_2.10/0.4.2/jars/scala-io-core_2.10.jar:/opt/play-2.2.1/repository/local/com.jsuereth/scala-arm_2.10/1.3/jars/scala-arm_2.10.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/play-iteratees_2.10/2.2.1/jars/play-iteratees_2.10.jar:/opt/play-2.2.1/repository/local/org.scala-stm/scala-stm_2.10/0.7/jars/scala-stm_2.10.jar:/opt/play-2.2.1/repository/local/com.typesafe/config/1.0.2/bundles/config.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/play-json_2.10/2.2.1/jars/play-json_2.10.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/play-functional_2.10/2.2.1/jars/play-functional_2.10.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/play-datacommons_2.10/2.2.1/jars/play-datacommons_2.10.jar:/opt/play-2.2.1/repository/local/joda-time/joda-time/2.2/jars/joda-time.jar:/opt/play-2.2.1/repository/local/org.joda/joda-convert/1.3.1/jars/joda-convert.jar:/opt/play-2.2.1/repository/local/com.fasterxml.jackson.core/jackson-annotations/2.2.2/jars/jackson-annotations.jar:/opt/play-2.2.1/repository/local/com.fasterxml.jackson.core/jackson-core/2.2.2/jars/jackson-core.jar:/opt/play-2.2.1/repository/local/com.fasterxml.jackson.core/jackson-databind/2.2.2/jars/jackson-databind.jar:/opt/play-2.2.1/framework/sbt/boot/scala-2.10.2/lib/scala-reflect.jar:/opt/play-2.2.1/repository/local/io.netty/netty/3.7.0.Final/bundles/netty.jar:/opt/play-2.2.1/repository/local/com.typesafe.netty/netty-http-pipelining/1.1.2/jars/netty-http-pipelining.jar:/opt/play-2.2.1/repository/local/org.slf4j/slf4j-api/1.7.5/jars/slf4j-api.jar:/opt/play-2.2.1/repository/local/org.slf4j/jul-to-slf4j/1.7.5/jars/jul-to-slf4j.jar:/opt/play-2.2.1/repository/local/org.slf4j/jcl-over-slf4j/1.7.5/jars/jcl-over-slf4j.jar:/opt/play-2.2.1/repository/local/ch.qos.logback/logback-core/1.0.13/jars/logback-core.jar:/opt/play-2.2.1/repository/local/ch.qos.logback/logback-classic/1.0.13/jars/logback-classic.jar:/opt/play-2.2.1/repository/local/com.typesafe.akka/akka-actor_2.10/2.2.0/jars/akka-actor_2.10.jar:/opt/play-2.2.1/repository/local/com.typesafe.akka/akka-slf4j_2.10/2.2.0/bundles/akka-slf4j_2.10.jar:/opt/play-2.2.1/repository/local/org.apache.commons/commons-lang3/3.1/jars/commons-lang3.jar:/opt/play-2.2.1/repository/local/com.ning/async-http-client/1.7.18/jars/async-http-client.jar:/opt/play-2.2.1/repository/local/oauth.signpost/signpost-core/1.2.1.2/jars/signpost-core.jar:/opt/play-2.2.1/repository/local/oauth.signpost/signpost-commonshttp4/1.2.1.2/jars/signpost-commonshttp4.jar:/opt/play-2.2.1/repository/local/commons-logging/commons-logging/1.1.1/jars/commons-logging.jar:/opt/play-2.2.1/repository/local/xerces/xercesImpl/2.11.0/jars/xercesImpl.jar:/opt/play-2.2.1/repository/local/xml-apis/xml-apis/1.4.01/jars/xml-apis.jar:/opt/play-2.2.1/repository/local/javax.transaction/jta/1.1/jars/jta.jar:/opt/play-2.2.1/framework/../repository/cache/securesocial/securesocial_2.10/jars/securesocial_2.10-master-SNAPSHOT.jar:/opt/play-2.2.1/repository/local/com.typesafe.play/play-cache_2.10/2.2.1/jars/play-cache_2.10.jar:/opt/play-2.2.1/repository/local/net.sf.ehcache/ehcache-core/2.6.6/jars/ehcache-core.jar:/opt/play-2.2.1/framework/../repository/cache/com.typesafe/play-plugins-util_2.10/jars/play-plugins-util_2.10-2.2.0.jar:/opt/play-2.2.1/framework/../repository/cache/com.typesafe/play-plugins-mailer_2.10/jars/play-plugins-mailer_2.10-2.2.0.jar:/opt/play-2.2.1/framework/../repository/cache/org.apache.commons/commons-email/jars/commons-email-1.2.jar:/opt/play-2.2.1/framework/../repository/cache/javax.mail/mail/jars/mail-1.4.1.jar:/opt/play-2.2.1/framework/../repository/cache/javax.activation/activation/jars/activation-1.1.jar:/opt/play-2.2.1/framework/../repository/cache/org.mindrot/jbcrypt/jars/jbcrypt-0.3m.jar:/opt/play-2.2.1/framework/../repository/cache/com.pellucid/aws-wrap_2.10/jars/aws-wrap_2.10-0.5-RC3.jar:/opt/play-2.2.1/framework/../repository/cache/com.amazonaws/aws-java-sdk/jars/aws-java-sdk-1.6.0.jar:/opt/play-2.2.1/framework/../repository/cache/org.apache.httpcomponents/httpclient/jars/httpclient-4.2.jar:/opt/play-2.2.1/framework/../repository/cache/org.apache.httpcomponents/httpcore/jars/httpcore-4.2.jar:/opt/play-2.2.1/repository/local/commons-codec/commons-codec/1.6/jars/commons-codec.jar -bootclasspath /usr/lib/jvm/jdk1.7.0_45/jre/lib/resources.jar:/usr/lib/jvm/jdk1.7.0_45/jre/lib/rt.jar:/usr/lib/jvm/jdk1.7.0_45/jre/lib/sunrsasign.jar:/usr/lib/jvm/jdk1.7.0_45/jre/lib/jsse.jar:/usr/lib/jvm/jdk1.7.0_45/jre/lib/jce.jar:/usr/lib/jvm/jdk1.7.0_45/jre/lib/charsets.jar:/usr/lib/jvm/jdk1.7.0_45/jre/lib/jfr.jar:/usr/lib/jvm/jdk1.7.0_45/jre/classes:/opt/play-2.2.1/framework/sbt/boot/scala-2.10.2/lib/scala-library.jar -unchecked
[error] 
[error]   last tree to typer: Literal(Constant(play.api.templates.Html))
[error]               symbol: null
[error]    symbol definition: null
[error]                  tpe: Class(classOf[play.api.templates.Html])
[error]        symbol owners: 
[error]       context owners: anonymous class anonfun$f$1 -> package html
[error] 
[error] == Enclosing template or block ==
[error] 
[error] Template( // val <local $anonfun>: <notype>, tree.tpe=views.html.anonfun$f$1
[error]   "scala.runtime.AbstractFunction1", "scala.Serializable" // parents
[error]   ValDef(
[error]     private
[error]     "_"
[error]     <tpt>
[error]     <empty>
[error]   )
[error]   // 3 statements
[error]   DefDef( // final def apply(title: String): Function1
[error]     <method> final <triedcooking>
[error]     "apply"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // title: String
[error]       <param> <triedcooking>
[error]       "title"
[error]       <tpt> // tree.tpe=String
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=Function1
[error]     Typed( // tree.tpe=Function1
[error]       Apply( // def <init>(arg$outer: views.html.anonfun$f$1,title$1: String): views.html.anonfun$apply$1, tree.tpe=views.html.anonfun$apply$1
[error]         new anonymous class anonfun$apply$1."<init>" // def <init>(arg$outer: views.html.anonfun$f$1,title$1: String): views.html.anonfun$apply$1, tree.tpe=(arg$outer: views.html.anonfun$f$1)views.html.anonfun$apply$1
[error]         // 2 arguments
[error]         This("$anonfun")final class anonfun$f$1 extends runtime.AbstractFunction1 with Serializable in package html, tree.tpe=views.html.anonfun$f$1
[error]         "title" // title: String, tree.tpe=String
[error]       )
[error]       <tpt> // tree.tpe=Function1
[error]     )
[error]   )
[error]   DefDef( // final def apply(v1: Object): Object
[error]     <method> final <bridge>
[error]     "apply"
[error]     []
[error]     // 1 parameter list
[error]     ValDef( // v1: Object
[error]       <param> <triedcooking>
[error]       "v1"
[error]       <tpt> // tree.tpe=Object
[error]       <empty>
[error]     )
[error]     <tpt> // tree.tpe=Object
[error]     Apply( // final def apply(title: String): Function1, tree.tpe=Function1
[error]       main$$anonfun$f$1.this."apply" // final def apply(title: String): Function1, tree.tpe=(title: String)Function1
[error]       Apply( // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=String
[error]         TypeApply( // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=()String
[error]           "v1"."$asInstanceOf" // final def $asInstanceOf[T0 >: ? <: ?](): T0 in class Object, tree.tpe=[T0 >: ? <: ?]()T0
[error]           <tpt> // tree.tpe=String
[error]         )
[error]         Nil
[error]       )
[error]     )
[error]   )
[error]   DefDef( // def <init>(): views.html.anonfun$f$1
[error]     <method> <triedcooking>
[error]     "<init>"
[error]     []
[error]     List(Nil)
[error]     <tpt> // tree.tpe=views.html.anonfun$f$1
[error]     Block( // tree.tpe=Unit
[error]       Apply( // def <init>(): scala.runtime.AbstractFunction1 in class AbstractFunction1, tree.tpe=scala.runtime.AbstractFunction1
[error]         main$$anonfun$f$1.super."<init>" // def <init>(): scala.runtime.AbstractFunction1 in class AbstractFunction1, tree.tpe=()scala.runtime.AbstractFunction1
[error]         Nil
[error]       )
[error]       ()
[error]     )
[error]   )
[error] )
[error] 
[error] == Expanded type of tree ==
[error] 
[error] ConstantType(value = Constant(play.api.templates.Html))
[error] 
[error] uncaught exception during compilation: java.io.IOException
[error] File name too long
[error] two errors found
[error] (compile:compile) Compilation failed

if I then run 'compile' a second time then it succeeds!

glidester avatar Jan 28 '14 11:01 glidester

This problem really occurs on encrypted home folders in Ubuntu. I solved the problem by creating another folder /home/unencrypted and copied my project there. Before i added scalacOptions ++= Seq("-Xmax-classfile-name", "254") and ran clean compile but without moving everything to /home/unencrypted it did not work.

axaluss avatar Jan 28 '14 18:01 axaluss

That workaround does not help on encrypted filesystems like encfs/cryptfs because it limits the plaintext filename length only. The filename encryption can create much longer filenames that hit the maximum filename length in the underlying filesystem, so when running on encfs/cryptfs you need a much much lower limit for "-Xmax-classfile-name".

hoxu avatar Jan 28 '14 18:01 hoxu

Well as I stated previously, I do not have an encrypted file system (I checked, I also moved my project to a usb stick and the problem remained).

Running 'clean' and then 'compile' causes the error. Running 'compile' a second time works with no error! Its all very odd behaviour.

glidester avatar Jan 29 '14 09:01 glidester

Ok, this error is too random to reliably reproduce. I can't seem to recreate it at all now. Not sure if restarting my computer this morning altered the state of something somewhere on my machine.

Thanks guys for the tips anyway

glidester avatar Jan 29 '14 09:01 glidester

At least we know some approaches to fix the problem. In a nutshell: clean compile compile In case of a encrypted home folder: add and adjust the -Xmax-classfile-name i.e. to 100 scalacOptions ++= Seq("-Xmax-classfile-name", "100") clean compile compile if this did not fix the problem move the project to another folder /home/unencrypted clean compile compile

axaluss avatar Jan 29 '14 09:01 axaluss

This might also be related to: https://issues.scala-lang.org/browse/SI-8199

There is sort of an off-by-one error in the limit.

I'm fixing this in 2.11.0

retronym avatar Jan 29 '14 09:01 retronym

I had the same problem compiling playframework 2.2.2 from sources, restricting the file size to 254 did not help, moving the sources to unencrypted directory did the trick. I am on ubunutu as well.

patrik7 avatar Apr 02 '14 17:04 patrik7

Hi,

Just link your project target directory to a directory outside the encrypted directory.

From inside you project directory (the directory containing the target folder) run this command:

ln -s /tmp target

Note: Cleaning your build (e.g. using 'sbt clean') may delete the target soft link and recreate the original directory, which will again give you the 'file name too long' issue, so after doing sbt clean, just delete the new target directory and create the link again.

rm -r -f target/ ln -s /tmp target

Cheers, Jacobus

p.s. Take care when using commands like rm -r -f on linux ;-)

jacobus avatar Jan 14 '15 07:01 jacobus

I get this error on CircleCI. I am assuming that it's due to encrypted file system but it only occurs where I use pickling so I think it still qualifies as a bug in pickling.

amogh09 avatar Feb 20 '18 07:02 amogh09