2017-01-15 3 views
0

Je me suis inscrit à des cours de Scala Functional Programming Coursera et j'ai travaillé sur les exercices de configuration initiaux que j'ai rencontrés dans ce numéro.Scala versions confusion

Lorsque vous essayez de compiler un « Bonjour tout le monde » projet SBT throught terminal de IntelliJ IDEA Je cette erreur

[error]  while compiling: /home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/src/main/scala/example/ExampleApp.scala 
[error]   during phase: typer 
[error]  library version: version 2.10.4 
[error]  compiler version: version 2.10.4 

il y a plus à lui, mais le cœur du problème est le suivant - scalac est fixé à 2.10. 4 (and everything 2.10.4 and less is not competible with Java 8) quand dans le build.sbt je l'ai mis à 2.12.1:

name := "example" 

version := "1.0" 

scalaVersion := "2.12.1" 

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.1" 

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test" 

libraryDependencies ++= Seq(
    "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6", 
    "org.scala-lang" % "scala-reflect" % "2.12.1", 
    "org.scala-lang" % "scala-library" % "2.12.1" 
) 

Et c'est la version sur le chemin de classe:

enter image description here

Cependant, même en essayant simple scala -version dans le terminal de la racine du projet Je sais utilise une version antérieure:

[[email protected] example]$ scala -version 
Scala code runner version 2.10.4 -- Copyright 2002-2013, LAMP/EPFL 
[[email protected] example]$ 

Je RÉGLER Scala à un endroit plus récent, mais cela n'a pas aide:

[[email protected] ~]$ echo $SCALA_HOME 
/usr/local/scala-2.11.8/ 

Je travaille sur Fedora 24. Toute aide sur la façon de changer d'emplacement pour scala, scalac, scalap sur mon OS aiderait, ou bien comment puis-je assurer que dans les projets, la version scala correcte est utilisé?

noter que j'ai essayé this advice de changer l'emplacement de scala, mais cela n'a pas fonctionné ni:

[[email protected] ~]$ sudo ln -s /usr/bin/scala /usr/local/scala-2.11.8/bin/scala 
[sudo] password for vgorcinschi: 
ln: failed to create symbolic link '/usr/local/scala-2.11.8/bin/scala': File exists 

MISE À JOUR

Ceci est la pleine stacktrace (comme appelé avec « dernière compilation: compilation):

[debug] 
[debug] Initial source changes: 
[debug]   removed:Set() 
[debug]   added: Set(/home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/src/main/scala/example/ExampleApp.scala) 
[debug]   modified: Set() 
[debug] Removed products: Set() 
[debug] Modified external sources: Set() 
[debug] Modified binary dependencies: Set() 
[debug] Initial directly invalidated sources: Set(/home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/src/main/scala/example/ExampleApp.scala) 
[debug] 
[debug] Sources indirectly invalidated by: 
[debug]   product: Set() 
[debug]   binary dep: Set() 
[debug]   external source: Set() 
[debug] All initially invalidated sources: Set(/home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/src/main/scala/example/ExampleApp.scala) 
[debug] Recompiling all 1 sources: invalidated sources (1) exceeded 50.0% of all sources 
[info] Compiling 1 Scala source to /home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/target/scala-2.12/classes... 
[debug] Getting compiler-interface from component compiler for Scala 2.12.1 
[debug] Getting compiler-interface from component compiler for Scala 2.12.1 
[debug] Running cached compiler 6bac1d44, interfacing (CompilerInterface) with Scala compiler version 2.10.4 
[debug] Calling Scala compiler with arguments (CompilerInterface): 
[debug]   -bootclasspath 
[debug]   /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/classes:/home/vgorcinschi/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.1.jar 
[debug]   -classpath 
[debug]   /home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/target/scala-2.12/classes:/home/vgorcinschi/.ivy2/cache/org.scalactic/scalactic_2.12/bundles/scalactic_2.12-3.0.1.jar:/home/vgorcinschi/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.12.1.jar:/home/vgorcinschi/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12/bundles/scala-xml_2.12-1.0.6.jar 
[error] 
[error]  while compiling: /home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/src/main/scala/example/ExampleApp.scala 
[error]   during phase: typer 
[error]  library version: version 2.10.4 
[error]  compiler version: version 2.10.4 
[error] reconstructed args: -bootclasspath /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-5.b16.fc24.x86_64/jre/classes:/home/vgorcinschi/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.1.jar -classpath /home/vgorcinschi/Documents/ideaProjects/CourseraScalaOne/example/target/scala-2.12/classes:/home/vgorcinschi/.ivy2/cache/org.scalactic/scalactic_2.12/bundles/scalactic_2.12-3.0.1.jar:/home/vgorcinschi/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.12.1.jar:/home/vgorcinschi/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12/bundles/scala-xml_2.12-1.0.6.jar 
[error] 
[error] last tree to typer: Literal(Constant(Hello, world!)) 
[error]    symbol: null 
[error] symbol definition: null 
[error]     tpe: String("Hello, world!") 
[error]  symbol owners: 
[error]  context owners: value <local ExampleApp> -> object ExampleApp -> package example 
[error] 
[error] == Enclosing template or block == 
[error] 
[error] Template(// val <local ExampleApp>: <notype> in object ExampleApp 
[error] "App" // parents 
[error] ValDef(
[error]  private 
[error]  "_" 
[error]  <tpt> 
[error]  <empty> 
[error] ) 
[error] // 2 statements 
[error] DefDef(// def <init>(): example.ExampleApp.type in object ExampleApp 
[error]  <method> 
[error]  "<init>" 
[error]  [] 
[error]  List(Nil) 
[error]  <tpt> // tree.tpe=example.ExampleApp.type 
[error]  Block(// tree.tpe=Unit 
[error]  Apply(// def <init>(): Object in class Object, tree.tpe=Object 
[error]   ExampleApp.super."<init>" // def <init>(): Object in class Object, tree.tpe=()Object 
[error]   Nil 
[error]  ) 
[error]  () 
[error] ) 
[error] ) 
[error] Apply(
[error]  "println" 
[error]  "Hello, world!" 
[error] ) 
[error]) 
[error] 
[error] == Expanded type of tree == 
[error] 
[error] ConstantType(value = Constant(Hello, world!)) 
[error] 
[error] uncaught exception during compilation: scala.reflect.internal.MissingRequirementError 
scala.reflect.internal.MissingRequirementError: class scala.annotation.serializable in compiler mirror not found. 
     at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:16) 
     at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:17) 
     at scala.reflect.internal.Mirrors$RootsBase$$anonfun$getModuleOrClass$3.apply(Mirrors.scala:49) 
     at scala.reflect.internal.Mirrors$RootsBase$$anonfun$getModuleOrClass$3.apply(Mirrors.scala:49) 
     at scala.reflect.internal.Symbols$Symbol.orElse(Symbols.scala:2229) 
     at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:48) 
     at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:61) 
     at scala.reflect.internal.Mirrors$RootsBase.getClassByName(Mirrors.scala:99) 
     at scala.reflect.internal.Mirrors$RootsBase.getRequiredClass(Mirrors.scala:102) 
     at scala.reflect.internal.Mirrors$RootsBase.requiredClass(Mirrors.scala:105) 
     at scala.reflect.internal.Definitions$DefinitionsClass.SerializableAttr$lzycompute(Definitions.scala:962) 
     at scala.reflect.internal.Definitions$DefinitionsClass.SerializableAttr(Definitions.scala:962) 
     at scala.reflect.internal.Symbols$Symbol.isSerializable(Symbols.scala:720) 
     at scala.tools.nsc.typechecker.SyntheticMethods$class.needsReadResolve$1(SyntheticMethods.scala:324) 
     at scala.tools.nsc.typechecker.SyntheticMethods$class.extras$1(SyntheticMethods.scala:357) 
     at scala.tools.nsc.typechecker.SyntheticMethods$class.synthesize$1(SyntheticMethods.scala:367) 
     at scala.tools.nsc.typechecker.SyntheticMethods$$anonfun$addSyntheticMethods$2.apply(SyntheticMethods.scala:400) 
     at scala.tools.nsc.typechecker.SyntheticMethods$$anonfun$addSyntheticMethods$2.apply(SyntheticMethods.scala:398) 
     at scala.reflect.internal.Trees$class.deriveTemplate(Trees.scala:1610) 
     at scala.reflect.internal.SymbolTable.deriveTemplate(SymbolTable.scala:13) 
     at scala.tools.nsc.typechecker.SyntheticMethods$class.addSyntheticMethods(SyntheticMethods.scala:398) 
     at scala.tools.nsc.Global$$anon$1.addSyntheticMethods(Global.scala:493) 
     at scala.tools.nsc.typechecker.Typers$Typer.finishMethodSynthesis(Typers.scala:1848) 
     at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1810) 
     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5584) 
     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642) 
     at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2928) 
     at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3032) 
     at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3032) 
     at scala.collection.immutable.List.loop$1(List.scala:170) 
     at scala.collection.immutable.List.mapConserve(List.scala:186) 
     at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3032) 
     at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5301) 
     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5587) 
     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642) 
     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5704) 
     at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:99) 
     at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:464) 
     at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91) 
     at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91) 
     at scala.collection.Iterator$class.foreach(Iterator.scala:727) 
     at scala.collection.AbstractIterator.foreach(Iterator.scala:1157) 
     at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:91) 
     at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1583) 
     at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1557) 
     at scala.tools.nsc.Global$Run.compileSources(Global.scala:1553) 
     at scala.tools.nsc.Global$Run.compile(Global.scala:1662) 
     at xsbt.CachedCompiler0.run(CompilerInterface.scala:123) 
     at xsbt.CachedCompiler0.run(CompilerInterface.scala:99) 
     at xsbt.CompilerInterface.run(CompilerInterface.scala:27) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:498) 
     at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102) 
     at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48) 
     at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41) 
     at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:98) 
     at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:98) 
     at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:98) 
     at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:159) 
     at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:97) 
     at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:142) 
     at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:86) 
     at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:38) 
     at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:36) 
     at sbt.inc.Incremental$.cycle(Incremental.scala:73) 
     at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:33) 
     at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:32) 
     at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:41) 
     at sbt.inc.Incremental$.compile(Incremental.scala:32) 
     at sbt.inc.IncrementalCompile$.apply(Compile.scala:26) 
     at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:150) 
     at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:70) 
     at sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:45) 
     at sbt.Compiler$.apply(Compiler.scala:70) 
     at sbt.Defaults$.sbt$Defaults$$compileTaskImpl(Defaults.scala:736) 
     at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:730) 
     at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:730) 
     at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) 
     at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42) 
     at sbt.std.Transform$$anon$4.work(System.scala:64) 
     at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237) 
     at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237) 
     at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18) 
     at sbt.Execute.work(Execute.scala:244) 
     at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237) 
     at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237) 
     at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160) 
     at sbt.CompletionService$$anon$2.call(CompletionService.scala:30) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
     at java.lang.Thread.run(Thread.java:745) 
[error] (compile:compile) scala.reflect.internal.MissingRequirementError: class scala.annotation.serializable in compiler mirror not found. 
+0

Vous pouvez tout faire passer par 'sbt'. Si vous voulez 'scala' pour le REPL, essayez' sbt console' à la place. Cela va prendre vos paramètres de construction. – Thilo

+0

Il n'a pas ramassé la version de construction - exactement la même erreur – vasigorc

+0

si vous "cd" dans le répertoire avec le 'build.sbt' et exécutez' sbt console' il vous donne une version de scala autre que celle spécifiée dans 'build .sbt'? – Thilo

Répondre

0

Enfin, je n'ai pas réussi à le résoudre. J'ai soulevé un problème avec le groupe sbt github et ils l'ont marqué comme bug: https://github.com/sbt/sbt/issues/2923

Cependant le "buggé" rpm était 0.13.13, je ne l'ai pas utilisé j'ai utilisé 0.13.13.1 (qui inclut le correctif), donc ils regardent toujours dedans. Comme je devais aller de l'avant avec la classe, j'ai installé Ubuntu 16.04 au lieu de mon Fedora 24 où tout fonctionne sans problème.