wix-incubator / accord

Accord: A sane validation library for Scala
http://wix.github.io/accord/
Other
529 stars 55 forks source link

Upgrade from 0.6.1 to 0.7 produces strange FileNotFoundException errors #117

Closed dpalinic closed 7 years ago

dpalinic commented 7 years ago

Summary: I upgraded wix accord from 0.6.1 to 0.7 and started receiving bunch of strange errors during the compile time: java.io.FileNotFoundException: /Users/tomerga/dev/accord/core/.jvm/target/scala-2.11/scoverage-data/scoverage.measurements.55 (No such file or directory)

Please note I'm not user tomerga mentioned in log line.

Log:

[info] Resolving jline#jline;2.12.1 ...
[error] /home/dpalinic/Workspace/projects/personal/public-transit-services/identity-api/src/main/scala/io/digitalcat/publictransit/services/identity/api/request/UserCreation.scala:19: exception during macro expansion: 
[error] java.io.FileNotFoundException: /Users/tomerga/dev/accord/core/.jvm/target/scala-2.11/scoverage-data/scoverage.measurements.55 (No such file or directory)
[error]     at java.io.FileOutputStream.open0(Native Method)
[error]     at java.io.FileOutputStream.open(FileOutputStream.java:270)
[error]     at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
[error]     at java.io.FileWriter.<init>(FileWriter.java:107)
[error]     at scoverage.Invoker$$anonfun$1.apply(Invoker.scala:42)
[error]     at scoverage.Invoker$$anonfun$1.apply(Invoker.scala:42)
[error]     at scala.collection.concurrent.TrieMap.getOrElseUpdate(TrieMap.scala:901)
[error]     at scoverage.Invoker$.invoked(Invoker.scala:42)
[error]     at com.wix.accord.transform.ExpressionDescriber$class.$init$(ExpressionDescriber.scala:46)
[error]     at com.wix.accord.transform.ValidationTransform.<init>(ValidationTransform.scala:25)
[error]     at com.wix.accord.transform.ValidationTransform$.apply(ValidationTransform.scala:240)
[error]   implicit val userCreationValidator = validator[UserCreation] { u =>
[error]                         

UserCreation class:

case class UserCreation(
  firstName: String,
  lastName: String,
  email: String,
  username: String,
  password: String
) 

object UserCreation {
  implicit val format: Format[UserCreation] = Json.format

  implicit val userCreationValidator = validator[UserCreation] { u =>
    u.firstName as notEmptyKey("firstName") is notEmpty
    u.lastName as notEmptyKey("lastName") is notEmpty
    u.email as matchRegexFullyKey("email") should matchRegexFully(Matchers.Email)
    u.username as notEmptyKey("username") is notEmpty
    u.username as sizeKey("username") has size > 5
    u.password as notEmptyKey("password") is notEmpty
    u.password as sizeKey("password")  has size > 7
  }
}
holograph commented 7 years ago

That is very strange. Can you share the relevant part of your build file? I'll try to reproduce this locally regardless. Thank you for the report!

dpalinic commented 7 years ago

Hi @holograph ,

Thanks for the response. Please checkout following github project which is build with Lagom Framework in Scala: https://github.com/dpalinic/lagom-jwt-authentication

  1. In build.sbt bump accord version from 0.6.1 to 0.7: Replace val accord = "com.wix" %% "accord-core" % "0.6.1" with val accord = "com.wix" %% "accord-core" % "0.7"
  2. In ValidationUtil.scala replace line 19 key = Descriptions.render(violation.description) with key = Descriptions.render(violation.path) to solve migration issue.
  3. Run sbt compile

Error:

[error]                                                                ^
[error] /home/dpalinic/Workspace/projects/personal/lagom-jwt-authentication/identity-api/src/main/scala/io/digitalcat/publictransportation/services/identity/api/request/UserLogin.scala:14: exception during macro expansion: 
[error] java.io.FileNotFoundException: /Users/tomerga/dev/accord/core/.jvm/target/scala-2.11/scoverage-data/scoverage.measurements.62 (No such file or directory)
[error]     at java.io.FileOutputStream.open0(Native Method)
[error]     at java.io.FileOutputStream.open(FileOutputStream.java:270)
[error]     at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
[error]     at java.io.FileWriter.<init>(FileWriter.java:107)
[error]     at scoverage.Invoker$$anonfun$1.apply(Invoker.scala:42)
[error]     at scoverage.Invoker$$anonfun$1.apply(Invoker.scala:42)
[error]     at scala.collection.concurrent.TrieMap.getOrElseUpdate(TrieMap.scala:901)
[error]     at scoverage.Invoker$.invoked(Invoker.scala:42)
[error]     at com.wix.accord.transform.ExpressionDescriber$class.$init$(ExpressionDescriber.scala:46)
[error]     at com.wix.accord.transform.ValidationTransform.<init>(ValidationTransform.scala:25)
[error]     at com.wix.accord.transform.ValidationTransform$.apply(ValidationTransform.scala:240)
[error]   implicit val userLoginValidation = validator[UserLogin] { u =>

I can reproduce this every time.

Thanks, Damir

holograph commented 7 years ago

Very strange, I cannot reproduce this issue at all:

> clean
[success] Total time: 1 s, completed Jul 25, 2017 10:43:38 AM
> compile
[info] Updating {file:/Users/tomerga/research/lagom-jwt-authentication/}common...
[info] Updating {file:/Users/tomerga/research/lagom-jwt-authentication/}public-transportation-services...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Updating {file:/Users/tomerga/research/lagom-jwt-authentication/}identity-api...
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.5 ...
[info] Compiling 9 Scala sources to /Users/tomerga/research/lagom-jwt-authentication/common/target/scala-2.11/classes...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Updating {file:/Users/tomerga/research/lagom-jwt-authentication/}identity-impl...
[info] Resolving com.typesafe#config;1.3.0 ...
[info] Compiling 8 Scala sources to /Users/tomerga/research/lagom-jwt-authentication/identity-api/target/scala-2.11/classes...
[info] Resolving com.lightbend.lagom#build-link;1.3.4 ...
[info] Done updating.
[info] Compiling 10 Scala sources to /Users/tomerga/research/lagom-jwt-authentication/identity-impl/target/scala-2.11/classes...
[success] Total time: 10 s, completed Jul 25, 2017 10:43:50 AM

I'm not actually sure what is going on here, but I do have a theory: do you happen to have scoverage as a global sbt plugin?

holograph commented 7 years ago

Actually ignore that, I'm an idiot and forgot to remove the "offending" directory. Looking into it some more.

holograph commented 7 years ago

Well, this turns out to be an egregious error on my part: scoverage was enabled for publishing. I think this is highly problematic default behavior (see my comment on scoverage/sbt-scoverage#84), but is never-the-less the culprit.

I'll be releasing 0.7.1 to solve this within the next few hours; thank you for the report @dpalinic!