Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

IOException on compilation (filename too long). #10

Open
Synesso opened this issue Aug 1, 2013 · 18 comments
Open

IOException on compilation (filename too long). #10

Synesso opened this issue Aug 1, 2013 · 18 comments
Labels

Comments

@Synesso
Copy link

Synesso commented Aug 1, 2013

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

@eklavya
Copy link

eklavya commented Sep 19, 2013

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

@heathermiller
Copy link
Member

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

Thanks for your patience!

@futurechimp
Copy link

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.

@yashton
Copy link

yashton commented Oct 29, 2013

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.

@hoxu
Copy link

hoxu commented Dec 29, 2013

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.

@axaluss
Copy link

axaluss commented Jan 17, 2014

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.

@nietaki
Copy link

nietaki commented Jan 19, 2014

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

@glidester
Copy link

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
Copy link

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!

@axaluss
Copy link

axaluss commented Jan 28, 2014

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.

@hoxu
Copy link

hoxu commented Jan 28, 2014

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".

@glidester
Copy link

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
Copy link

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

@axaluss
Copy link

axaluss commented Jan 29, 2014

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

@retronym
Copy link
Member

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

@patrik7
Copy link

patrik7 commented Apr 2, 2014

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.

@jacobus
Copy link

jacobus commented Jan 14, 2015

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 ;-)

@eed3si9n eed3si9n removed this from the 0.10.1 milestone May 15, 2015
aguestuser added a commit to whereat/whereat-location-server that referenced this issue Jan 27, 2016
* fixes problems with compiling on encrypted harddrives
* as per: <scala/pickling#10>
n10n pushed a commit to n10n/SpecialK that referenced this issue Apr 9, 2016
n10n pushed a commit to n10n/agent-service-ati-ia that referenced this issue Apr 9, 2016
@amogh09
Copy link

amogh09 commented Feb 20, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

16 participants