Ammonite enhances the Scala REPL and Scala scripts. It also allows Scala to be used as an interactive bash replacement.
Questions tagged [ammonite]
67 questions
1
vote
1 answer
How to use resources from an Ammonite script?
I have a few ammonite scripts, they are stored in a folder. That folder is on my PATH, so I can invoke those scripts easily wherever I am.
I can import other ammonite scripts in the same folder:
$import $file.
However I…

kurgan
- 83
- 9
1
vote
1 answer
Getting history out of ammonite
What is the best way to print history of code executed in ammonite repl in previous sessions? I am aware of repl.history but it contains code from current session and I know that ammonite keeps history of previous sessions because snippets from them…

Łukasz Biały
- 431
- 5
- 14
1
vote
1 answer
How can I control the Java version used with Ammonite
In my Linux system I have several Java versions installed.
How can I control the version used to launch an Ammonite script?

david.perez
- 6,090
- 4
- 34
- 57
1
vote
2 answers
Unable to recover typeclass instances for types with kind F[A1, A2] with syntax extensions
I've been playing around with the typeclass pattern in Scala to better understand how it works, as I'm familiar with Scalaz and wanted to figure out how it works "under the hood".
(You can run the following code with https://ammonite.io/…

Max Bo
- 111
- 1
- 11
1
vote
1 answer
How to run Scala REPL commands in ammonite REPL/SHELL?
I mean commands like :t :type to check type of expressions or any other kinds of commands.
The idea behind ammonite really attracts me and now I'm trying to use it to get more familiar with scala.
These commands are helpful to me as a beginner, but…

Wan ChengCheng
- 57
- 4
1
vote
0 answers
Running out of heap memory while compiling an Ammonite script
I'm trying to create a script that uses the Slick Code Generator to map an entire database to a Scala file, running up a docker container, and executing the ddl on a database running inside of it, effectively rebuilding the database every time it's…

Raudbjorn
- 450
- 2
- 8
1
vote
0 answers
How to create a Scala presentation compiler inside Ammonite REPL?
I want to create a Scala presentation compiler in Ammonite REPL, however I always got the error of Missing dependency 'object scala in compiler mirror'.
I have tried the workaround mentioned in object scala in compiler mirror not found - running…

Yang Bo
- 3,586
- 3
- 22
- 35
1
vote
1 answer
Create a class with a package in a Scala Ammonite Script
I have written the following scala script in ammonite shell
#!/usr/bin/env amm
@main
def main() = {
val p = Person("foo")
}
case class Person(name: String)
This compiles and works fine. But I need the class Person to be in a package called…

Knows Not Much
- 30,395
- 60
- 197
- 373
1
vote
1 answer
Running SBT from an ammonite script
I am trying to write a ammonite script which triggers an SBT task.
So far this is what I have written.
test.sh
#!/usr/bin/env amm
import sys.process._
import java.io.File
import ammonite.ops._, ImplicitWd._
@main
def ini(args: String*) = {
val…

Knows Not Much
- 30,395
- 60
- 197
- 373
1
vote
1 answer
Ammonite and Akka-Http config file error
I'm trying to embed an akka-http server into my ammonite scala script.
Below is the scala code used to create a server instance
import ammonite.ops._
import $ivy.`com.typesafe:config:1.3.1`
import…

mvito
- 75
- 3
1
vote
1 answer
How to get the name of the current script?
How do I get the name of the current script?
For example if I run myscript.sc, I'd like to know the value of myscript
I need this for killing previous instances of the script, still running.

david.perez
- 6,090
- 4
- 34
- 57
1
vote
1 answer
Is there any special support for environment variable access in Ammonite?
I'm wondering if ammonite has a convenient, shorthand way to access environment variables from the parent process, or is scala.util.Properties.envOrElse the suggested method? (How to read environment variables in Scala)
Related: is there a way to…

bbarker
- 11,636
- 9
- 38
- 62
1
vote
1 answer
Is it possible to nest command calls in the Scala Ammonite shell?
I'm trying to translate a typical UNIX command jmap -heap $(pgrep java) to a command for the Ammonite-Shell.
My attempt so far: %'jmap("-heap", %'pgrep("java")).
I get the error SyntaxError: found "%'jmap(\"-heap\", %'pg", expected "while" | ...…

bbarker
- 11,636
- 9
- 38
- 62
1
vote
0 answers
How to use the same initialCommands with and without ammonite
I work on a project and I want to let the choice of using ammonite at each developer.
So I have to share the initialCommands to avoid dups.
Here are my current solution.
val initCommands = s""" val sc = new org.apache.spark.SparkContext("local",…

Yann Moisan
- 8,161
- 8
- 47
- 91
0
votes
0 answers
java.lang.AssertionError: assertion failed when running Ammonite
I have installed scala 3.2.2, which includes ammonite, coursier, scala repl. When trying to run ammonite I receive the following error:
C:\Users\myuser>amm
Loading...
Welcome to the Ammonite Repl 3.0.0-M0-19-62705f47 (Scala 3.2.2 Java 11.0.15)
@…

Victor M Perez
- 2,185
- 3
- 19
- 22