Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jan 30 2019 14:37
    bhaskarmelkani starred lihaoyi/Ammonite
  • Jan 29 2019 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 29 2019 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 28 2019 15:07
    ishubelko starred lihaoyi/Ammonite
  • Jan 25 2019 22:38
    borissmidt starred lihaoyi/Ammonite
  • Jan 25 2019 17:12

    alexarchambault on 1.6.3


  • Jan 25 2019 17:11

    alexarchambault on master

    1.6.3 (compare)

  • Jan 25 2019 15:48
    alexarchambault commented #923
  • Jan 25 2019 01:15

    lihaoyi on gh-pages

    5ad9ae5538f23cab92ccd8c6b1617d8… (compare)

  • Jan 25 2019 00:50

    alexarchambault on master

    Partly revert 84d48542 (#923) … (compare)

  • Jan 25 2019 00:50
    alexarchambault closed #923
  • Jan 25 2019 00:50
    alexarchambault closed #920
  • Jan 25 2019 00:50
    alexarchambault closed #922
  • Jan 24 2019 23:13
    lihaoyi commented #923
  • Jan 24 2019 22:39
    alexarchambault closed #921
  • Jan 24 2019 22:39
    alexarchambault commented #921
  • Jan 24 2019 22:39
    alexarchambault edited #923
  • Jan 24 2019 22:38
    alexarchambault opened #923
  • Jan 24 2019 22:37
    david-bouyssie commented #919
  • Jan 24 2019 21:33
    nksureshkumar commented #922
Brian Maso
:thumbsup: That's pretty cool
On ubuntu, I am not seeing the color syntax highlighting for error stack trace (its all red). Colors are working normally otherwise. Amm 1.7.1
Milan Satala

Hi guys,
ammonite-sshd doesn't run predef when running inside docker container.
I'm running ammonite embedded in play server. When I start play via runProd and connect to ammonite via ssh I get this

Compiling /home/milan/dev/traceability/traceability/server/playserver/target/universal/stage/(console)
Setting front-end. // My println in predef
Welcome to the Ammonite Repl 1.7.4

However when I run the same play server inside alpine-java docker container I only get this:

Welcome to the Ammonite Repl 1.7.4

Any ideas?

Glen Marchesani
anyone know of a simple way to use ammonite as a server side scripting language ?
Olivier Mélois
@fizzy33 can you refine your question ? ammonite provides you with a way to access a repl over ssh, and you can can embed it in a server : http://ammonite.io/#RemoteREPL , but that might not be what you need
@msatala chances your docker container doesn't see your predef. It's likely a docker problem, not an ammonite problem.
Abhishek Srivastava
I am having a problem with ammonite with international characters. Try to copy and paste this string into ammonite (on macOS).
Now move the cursor to the beginning of the line and try to move the cursor to the end. you will see that the cursor gets stuck at the character . Even Cmd+E doesn't work and it doesn't take you to the end of the line.
This doesn't happen in Scala REPL or Bash. only in ammonite it gets stuck
Emmanuel Nhan
Hi there, I am using sbt 1.3.2 and I try to use ammonite 1.7.4 with a commandAlias. It works, but the supershell feature of sbt makes it almost unusable. Is there a way to deactivate supershell for just one task ? I tried Test / useSuperShell := falsebut it did not work. Does someone has an alternative workaround than just calling sbt with --supershell=false ?
Abhishek Srivastava

I had the following two lines in my predef.sc

import coursier.MavenRepository
interp.repositories() ++= Seq(MavenRepository("https://repository.mulesoft.org/nexus/content/repositories/public/"))

These used to work fine. today I upgraded my ammonite to 1.7.4 and now its broken. Error

predef.sc:17: not found: value coursier
import coursier.MavenRepository
Abhishek Srivastava
OK. I was able to resolve the issue of MavenRepository. The updated code is like this
import coursierapi.MavenRepository
interp.repositories() ++= Seq(
Now it works fine.
Zsolt Szilagyi
@abhishes_twitter I have the same issue, but I also need authentication. Couldn't manage to make it work yet.
Natalia Tisseyre
Is it possible to have 2 ScalaInterpreters in the single JVM process who share same classLoader? I ran into ClassCastException when trying to deserialize/serialize some instances created by a different classLoader: almond-sh/almond#452
Haifeng Li

I develop a small DSL in scala. It works in Scala's REPL. But in Ammonite, I get the following error:

@ val formula = "class" ~ 
cmd2.sc:1: value ~ is not a member of String
val formula = "class" ~
Compilation Failed

All my classes and implicit conversation are already imported.

The same expression works in Scala REPL
scala> val formula = "class" ~
formula: smile.data.formula.FormulaBuilder = FormulaBuilder(Some(class),ListBuffer())
Haifeng Li
Never mind. I find the root cause. It is on my end.
hello all, thanks for such a great package!
I am running into "org.apache.spark.sql.AnalysisException: Unable to generate an encoder for inner class ammonite.$sess.cmd29$Helper$SimpleTuple without access to the scope that this class was defined in.
Try moving this class out of its parent class.;" and google searches are not too helpful at the moment
can anyone help me get through this?
Just mapping values of a dataset to
case class SimpleTuple(id: Int, desc: String) {
    def >(other:SimpleTuple) = this.id > other.id
So here's what I had to do to make this work
case class SimpleTuple4(id: Int, desc: String) {
    def >(other:SimpleTuple4) = this.id > other.id
textFile.map(line => SimpleTuple4(line.split(" ").size,line)).reduce((a, b) => if (a > b) a else b)
all within the same cell
is this the current workaround? This is Spark 2.4.4
Sören Brunk
@phrmoy yes, on Spark master this is included by default, but it seems it's not part of 2.4. See https://github.com/apache/spark/pull/23607/files#diff-28a2ffae3ceff1bd5646567163c3a00b
Well, it's great to know that this will be included in Spark at some point. Thanks for sharing.
Li Haoyi
@/all Ammonite 1.8.0 is out http://ammonite.io/#1.8.0, with an OS-Lib upgrade
Diego E. Alonso Blas
Good morning.
Is there a way of run an ammonite console in sbt, as an alternative to sbt console, that will load the files in the project?
I have tried writing a Main as suggested in https://ammonite.io/#Debugging, and running it with the run command inside sbt , but that did not work...
Emmanuel Nhan

@diesalbla Use this :

libraryDependencies += {
  val version = scalaBinaryVersion.value match {
    case "2.10" => "1.0.3"
    case _ ⇒ "1.8.0"
  "com.lihaoyi" % "ammonite" % version % "test" cross CrossVersion.full

sourceGenerators in Test += Def.task {
  val file = (sourceManaged in Test).value / "amm.scala"
  IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")

and if you want, add a shortcut :
addCommandAlias("repl", "test:runMain amm")

Diego E. Alonso Blas
Emmanuel Nhan
@diesalbla by the way, it is in https://ammonite.io/#Ammonite-REPL section of the doc. Not under the "debugging" one.
Diego E. Alonso Blas
@enhan Do you have an example of some project with the full SBT configured? I am afraid it is still failing me...

Anyone familiar with importing from a secure private bintray? I've tried to follow various snippets I've found through Google, but can't make it go.

import coursier.core.Authentication, coursier.MavenRepository

interp.repositories() ++= Seq(MavenRepository(
      authentication = Some(Authentication("user", "pass"))

import $ivy.{

gives me

Failed to resolve ivy dependencies:Error downloading com.some:artifact_2.12:1.0.9-85
  not found: /Users/nderraugh/.ivy2/local/com.some/artifact_2.12/1.0.9-85/ivys/ivy.xml
  not found: https://repo1.maven.org/maven2/com/some/artifact_2.12/1.0.9-85/artifact_2.12-1.0.9-85.pom
Dmitriy Kuzkin

HI, may be somebody can assist

I have to call
git blame <file> | grep -n '^0{8} ' | cut -f1 -d:
This gives me line numbers of changed git files


Can I somehow to execut this as a native command, it just hungs

Dmitriy Kuzkin
Jakub Dubovsky
Hey all! I am looking into ways how to replace bash by ammonite for writing general non-interactive scripts. From existance of Ammonite-Shell/Scripting chapter in documentation I understand that this usecase is supported. One of essentials here is an ability to invoke system binaries. I see we have this ability throuhg %, %% commands. I have installed ammonite per instructions on ammonite.io. In this setup percent commands are available only when amm is run interactivly. This is because predef code with necessary imports is pre-executed only for interactive sessions. Should I solve this by importing predef file by hand in all my future scripts? Or is this a bad idea for some reason. If on the other hand it is a good idea why predef is not pre-executed when scripts are run non-interactively as well? Or is there another .ammonite file which is run before scripts like this? I hope you see my confusion. And thanks for ammonite!
Michael Pilquist
I know how to import libraries from an ammonite predef. How can I write a function/alias in an ammonite predef that imports libraries when function is run?
Michael Pilquist
Oh, repl.load.exec
Michael Pilquist
In case this is helpful to anyone else, here’s what I came up with:
import $plugin.$ivy.`org.typelevel:::kind-projector:0.11.0`

interp.configureCompiler(_.settings.YpartialUnification.value = true)

object load {
  def fs2Version(version: String) = {
    import $$ivy.`co.fs2::fs2-io:$version`, fs2._, fs2.concurrent._, cats._, cats.implicits._, cats.effect._, cats.effect.implicits._, scala.concurrent.duration._

    implicit val ioContextShift: ContextShift[IO] = IO.contextShift(scala.concurrent.ExecutionContext.Implicits.global)
    implicit val ioTimer: Timer[IO] = IO.timer(scala.concurrent.ExecutionContext.Implicits.global)
    if (!version.startsWith("1")) repl.load.apply("""
      val globalBlocker: Blocker = cats.effect.Blocker.liftExecutionContext(scala.concurrent.ExecutionContext.Implicits.global)

  def fs2 = fs2Version("2.0.1")
Chris Stewart
Does ammonite support reading from stdin using scala.io.StdIn.readLine()? I can't seem to terminate the input by hitting the "enter" key
Basically something simple like this println("Enter encrypted data:") val encryptedDataStr = scala.io.StdIn.readLine()
Chris Stewart
This is being run from bloop, if that matters

Hi everyone, can someone explain to me the behavior depicted in this screenshot?


I am saving a repl session and then import a script file which just contains a dummy function called test that simply prints "hi ho". Then I load the previously saved repl session again and import the file again but it cannot find the test function. Am I just not understanding something about file imports or is this strange behavior?

Li Haoyi
@mpilquist sorry I didn't see this, yeah that looks like about as good as you are going to get. If you want to do magicky things like change the set of things in local scope by calling a function, the eval-ish functions like repl.load.apply are how you do that
you could also write your own custom import hook, to do import $fs2.blahblahblah instead of calling a magic function, but that's not really any better. Just a different spelling in the end
Hey there! About ammonite in intellij support. It works well with dependencies but not with transitive dependencies. Has anyone solve this problem?
Tom Green
Hi I'm trying to use ls.rec.iter! as mentioned in the docs (I'm using amm-1.8.1 in scala 2.12.10) and it doesn't seem to exist. I've tried ever other thing I can think of. If this doesn't exist, is there a good replacement, or advice on the best way to use ammonite.ops to do a ls.rec on a huge tree in a "streaming" fashion?