Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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

    (compare)

  • 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
Jacob Taylor-Hindle
@GlassAndOneHalf

Hi all, I'm working to embed Ammonite in my application, and I'd like to be able to pass an object from the application to the Ammonite environment, e.g.

def my_entrypoint(foo: Foo) = {
  // Make `foo` accessible from the script.
  ammonite.Main(...).runScript(...)
}

I see the run method on Main would allow me to do this, but I want to be able to do this when running a script non-interactively - are there any methods that would allow me to achieve this?

Pascal Mengelt
@pme123
What happens if I have a Future in my Script? Will it run in the background forever?
Li Haoyi
@lihaoyi
@GlassAndOneHalf easiest thing to do is put it on a threadlocal
Jacob Taylor-Hindle
@GlassAndOneHalf
Hey @lihaoyi - how would I go about doing that? I can easily create a new threadlocal, but how does Ammonite pick that up?
Jacob Taylor-Hindle
@GlassAndOneHalf

I managed to get it working without a threadlocal with this:

ammoniteMain
  .instantiateRepl(IndexedSeq("foo" -> foo)).map { repl =>
    repl.interp.initializePredef()
    ammonite.main.Scripts.runScript(...)
}

The only issue is that it doesn't seem to pick up the @main annotations.

Jacob Taylor-Hindle
@GlassAndOneHalf
Ah - that was my bad. All is working now! Just need to fix some issues loading scripts under the resources folder.
Brian Maso
@bmaso
@GlassAndOneHalf +1. Wish I could bookmark that.
Ackerley Tng
@ackerleytng
@lihaoyi thanks so much for ammonite and great job!!
starting out in scala, was trying stuff out in ammonite - implicit conversions don't seem to take effect in the ammonite repl. is this expected behavior? (from Scala for the Impatient)
@ import scala.collection.JavaConverters.asScalaBufferConverter 
import scala.collection.JavaConverters.asScalaBufferConverter

@ val tmp: Buffer[String] = flavors.getNativesForFlavor(DataFlavor.imageFlavor) 
cmd44.sc:1: type mismatch;
 found   : java.util.List[String]
 required: scala.collection.mutable.Buffer[String]
val tmp: Buffer[String] = flavors.getNativesForFlavor(DataFlavor.imageFlavor)
                                                     ^
Compilation Failed
@
Li Haoyi
@lihaoyi
Hi Ackerley!
not sure about JavaConversions
Theyve been deprecated for a while, wouldn’t be surprised if they don’t work properly these days
Trond Bjerkestrand
@tbje

@ackerleytng try

flavors.getNativesForFlavor(DataFlavor.imageFlavor).asScala

Worked well in my ammonite

Li Haoyi
@lihaoyi
(need to import collections.JavaConverters._ before that)
Ackerley Tng
@ackerleytng
I see, got it! so it isn't really implicit anymore. Thanks!
Eric K Richardson
@ekrich
JavaConversions were implicit but they are deprecated.
Ackerley Tng
@ackerleytng
I see, thanks!
Matthew de Detrich
@mdedetrich
Is it possible to create a forked process with ammonite-ops?
Li Haoyi
@lihaoyi
you can spawn processes using os.proc().spawn. You cannot fork JVMs https://jukkaz.wordpress.com/2010/05/27/forking-a-jvm/
Matthew de Detrich
@mdedetrich
Thanks
Jonas Amundsen
@badeball
This might be a silly question, but can I import and use a file from a SBT project in a scala-script?
Jason Pickens
@steinybot

I’m trying to follow the steps to add Ammonite to an SBT project. Now when I run Test / compile it fails with:

[error] error while loading Object, Missing dependency 'object scala.native in compiler mirror', required by /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/rt.jar(java/lang/Object.class)
[error] ## Exception when compiling 1 sources to /Users/jason/source/console-api/target/scala-2.13/test-classes
[error] scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
…

This is with sbt 1.3.5 and Scala 2.13.1

Henry Story
@bblfish
Hi @lihaoyi just wondering as your code uses a lot of the symbol notation from Scala2 what you make of its deprecation in Scala3. Did you find a good workaround?
Li Haoyi
@lihaoyi
we’ll just use strings instead
one more character to type is no big deal
we never made use of symbol specific stuff anyway
Henry Story
@bblfish
+1
Adam Fraser
@adamgfraser
Hi. Is there a recommended best practice for avoiding having scripts exit an interactive Ammonite session if they call system.exit? I'm thinking of just checking sys.env for Ammonite being the main class and not doing the exit in that case but wanted to see if there was another recommended way.
Rey
@reyman
hi,

I'm trying to load scala-js-d3v4 lib using ammonite script of @lihaoyi without success,

interp.repositories() ++= Seq(coursierapi.IvyRepository.of("https://jitpack.io"))
import $ivy.`com.github.fdietze:scala-js-d3v4:master-SNAPSHOT`

I have a failed resolving error ... someone use d3 with scala js here ?

Rey
@reyman
i obtain something like that
something like that :
org.xml.sax.SAXParseException; lineNumber: 42; columnNumber: 3; Le type d'élément "meta" doit se terminer par la balise de fin correspondante "</meta>". (Le type d'élément "meta" doit se terminer par la balise
 de fin correspondante "</meta>".)
jvr-ks
@jvr-ks

I switched from MINGW64 to WSL / Debian buster on my Win10 laptop today.

Welcome to the Ammonite Repl 1.9.8
(Scala 2.13.1 Java 11.0.5)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi

Great!

One drawback:

I am used to use TABs to format code,

but Ammonite Repl uses TABs for autocompletion in interactive mode.

How can I turn this off ore replace with another key (Shift+Tab?) and use Tabs as Tabs,
besides replacing all TABs with blanks :-) ?

Rey
@reyman
hi @lihaoyi , i'm trying to add jitpack dependency to use scala js D3 with ammonite, i have a org.xml.sax error, i post an issue here, fdietze/scala-js-d3v4#41 , but dev doesn't know why lib is not downloaded by ammonite
Colin Williams
@KE7CFN_twitter
@bblfish I thought I would fiddle with banana-rdf but following https://github.com/banana-rdf/banana-rdf/wiki/Scripting-with-Ammonite and getting import errors.
amm
Loading...
Welcome to the Ammonite Repl 2.0.1
(Scala 2.12.10 Java 1.8.0_232)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
colin-banana-rdf@ import coursier.core.Authentication, coursier.MavenRepository 
cmd0.sc:1: not found: value coursier
import coursier.core.Authentication, coursier.MavenRepository
       ^
cmd0.sc:1: not found: value coursier
import coursier.core.Authentication, coursier.MavenRepository
                                     ^
Compilation Failed

colin-banana-rdf@  

colin-banana-rdf@ interp.repositories() ++= Seq(MavenRepository(
                    "http://bblfish.net/work/repo/snapshots/"
                    )) 
cmd0.sc:1: value ++= is not a member of List[coursierapi.Repository]
  Expression does not convert to assignment because:
    not found: value MavenRepository
    expansion: {
  <synthetic> val ev$1: ammonite.util.Ref[List[coursierapi.Repository]] = ammonite.interp.api.InterpBridge.value.repositories;
  ev$1.update(ev$1.apply().++(Seq(<MavenRepository: error>("http://bblfish.net/work/repo/snapshots/"))))
}
val res0 = interp.repositories() ++= Seq(MavenRepository(
                                 ^
Compilation Failed
Colin Williams
@KE7CFN_twitter
Colin Williams
@KE7CFN_twitter
That worked. I will update the wiki...
Colin Williams
@KE7CFN_twitter
Is there any set -x when running scala scripts? I found lihaoyi/Ammonite#421 but assume it's related to the REPL, and not scala scripts.
Kyle Prifogle
@kyprifog
Can anyone help me figure out how to structure an import statement for this in ammonite? https://github.com/MrPowers/spark-daria I assume you use $ivy, but that library doesn't seem to be there.
Ben Iofel
@benwaffle
interp.repositories() ++= Seq(coursierapi.MavenRepository.of("http://dl.bintray.com/spark-packages/maven"))

@

import $ivy.`mrpowers:spark-daria:0.35.0-s_2.12`
Kyle Prifogle
@kyprifog
Thank you! the top part was what I was missing
Kyle Prifogle
@kyprifog
Hmm, this doesn't work
Kyle Prifogle
@kyprifog
This worked for me:
import coursier._

val mavenRepo = coursier.MavenRepository("http://dl.bintray.com/spark-packages/maven")
interp.repositories.update(
  interp.repositories() ::: List(mavenRepo)
)
Ben Iofel
@benwaffle
is your version of ammonite out of date?
Kyle Prifogle
@kyprifog
version 2.0.1, from what I read on the issues on github the issue was that my version of ammonite was too up to date
that particular syntax had changed apparently
gavinbaumanis
@gavinbaumanis

I am trying the Machine Learning examples on the website,
When I run;

val tokenData = requests.get(tokenDataUrl)

I get the following - then a whole lot of "binary" data and the shell crashes.

Exception in thread "main" java.lang.IllegalArgumentException: Unknown ansi-escape

Here is the stack trace;

at fansi.ErrorMode$Throw$.handle(Fansi.scala:419)
        at fansi.ErrorMode$Throw$.handle(Fansi.scala:407)
        at fansi.Str$.apply(Fansi.scala:272)
        at fansi.Str$.implicitApply(Fansi.scala:227)
        at ammonite.repl.Repl$.$anonfun$showException$1(Repl.scala:304)
        at scala.collection.immutable.List.map(List.scala:219)
        at scala.collection.immutable.List.map(List.scala:79)
        at ammonite.repl.Repl$.showException(Repl.scala:300)
        at ammonite.repl.Repl$.handleRes(Repl.scala:258)
        at ammonite.repl.Repl.loop$1(Repl.scala:215)
        at ammonite.repl.Repl.run(Repl.scala:223)
        at ammonite.Main.$anonfun$run$1(Main.scala:224)
        at scala.Option.getOrElse(Option.scala:201)
        at ammonite.Main.run(Main.scala:212)
        at ammonite.MainRunner.$anonfun$runRepl$1(Main.scala:408)
        at ammonite.MainRunner.watchLoop(Main.scala:389)
        at ammonite.MainRunner.runRepl(Main.scala:408)
        at ammonite.Main$.main0(Main.scala:307)
        at ammonite.Main$.main(Main.scala:271)
        at ammonite.Main.main(Main.scala)
Chris
@PickledChris
is there a way of compiling a script without running it, so we can check scripts compile (without executing them) in CI?
padhia
@padhia
Are unmodified Ammonite scripts triggering recompilation and re-caching when invoked from a different current working directory a normal behavior? It seems odd for the compiled code to depend on the value of PWD.