alexarchambault / sbt-ammonite

SBT plugin to ease the launch of Ammonite
49 stars 8 forks source link

project import cannot be found by ammonite:run #14

Open barambani opened 8 years ago

barambani commented 8 years ago

Hi, I'm trying to use sbt-ammonite in a simple test project of mine but I'm having some troubles. The project can be found here

https://github.com/barambani/functional-programming-in-scala

As you can see in build.sbt I'm trying to import some dependencies as initial commands in console

initialCommands in console := """ |import ListExercise. |import TreeExercise. |import OptionExercise._ """.stripMargin

but when I try ammonite:run and they are passed as predef to the ammonite.repl.Main they cannot be found (see error below). The same build file works great if I use the sbt console instead.

Is there anything I can double check or that I might miss ? Thanks.

[info] Resolving com.lihaoyi#ammonite-repl2.11.8;0.7.8 ... [info] Done updating. [info] Compiling 3 Scala sources to /functional-programming-in-scala/target/scala-2.11/classes... [info] Running ammonite.repl.Main --predef [info] import ListExercise. [info] import TreeExercise. [info] import OptionExercise. Loading... Predef.scala:46: not found: value ListExercise ;import ListExercise. ^ Predef.scala:47: not found: value TreeExercise ;import TreeExercise. ^ Predef.scala:48: not found: value OptionExercise ;import OptionExercise._ ^ [error] (run-main-1) java.lang.RuntimeException: Error during Predef: Compilation Failed java.lang.RuntimeException: Error during Predef: Compilation Failed at ammonite.repl.interp.Interpreter$$anonfun$17.apply(Interpreter.scala:518) at ammonite.repl.interp.Interpreter$$anonfun$17.apply(Interpreter.scala:511) at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124) at scala.collection.immutable.List.foldLeft(List.scala:84) at ammonite.repl.interp.Interpreter.(Interpreter.scala:511) at ammonite.repl.Repl.(Repl.scala:41) at ammonite.repl.Main.instantiateRepl(Main.scala:57) at ammonite.repl.Main.run(Main.scala:68) at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:258) at ammonite.repl.Main$$anonfun$main$2.apply(Main.scala:244) at scala.Option.foreach(Option.scala:257) at ammonite.repl.Main$.main(Main.scala:244) at ammonite.repl.Main.main(Main.scala) 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) [trace] Stack trace suppressed: run last ammonite:run for the full output. java.lang.RuntimeException: Nonzero exit code: 1 at scala.sys.package$.error(package.scala:27) [trace] Stack trace suppressed: run last ammonite:run for the full output. [error] (ammonite:run) Nonzero exit code: 1 [error] Total time: 10 s, completed 05-Nov-2016 17:12:09

wasowski commented 7 years ago

Seeing the same issue

wasowski commented 7 years ago

Also the same issue appears, if one does not use the plugin, but attempts to integrate into sbt directly, as described here: http://www.lihaoyi.com/Ammonite/

libraryDependencies += "com.lihaoyi" % "ammonite" % "0.8.2" % "test" cross CrossVersion.full

initialCommands in (Test, console) := """ammonite.Main().run()"""

So perhaps this is an Ammonite issue.

samuelsayag commented 2 years ago

Hello,

I am having the same issue. The scala console of sbt find correctly my project packages but ammonite fails to see it and auto-completion just propose jar dependencies namespaces. With this ammonite in the context of bloop usage: Welcome to the Ammonite Repl 2.5.2 (Scala 2.13.8 Java 17.0.2)