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
Kevin Sjöberg
@kevinsjoberg
I see. How does that work when I'm using https://get-coursier.io?
Florian Schmaus
@Flowdalic
@kevinsjoberg I think very similar, I'd even assume that the release binaries are generated using coursier
All the the universal script at the beginning of the amm binary needs is a (recent enough) Java VM in PATH
Kevin Sjöberg
@kevinsjoberg
Sorry, @Flowdalic, I'm super new to the whole ecosystem, so I didn't quite follow. If I want to launch the Scala 3 version of Ammonite, what would I do? Btw, I also noticed I can do cs launch scalac -- -version and it prints out Scala compiler version 3.1.2 -- Copyright 2002-2022, LAMP/EPFL but if I try to do cs launch amm -- --version I get Cannot find app amm in channels io.get-coursier:apps.
Florian Schmaus
@Flowdalic
Ahh you want to fire up a Scala 3 amm using coursier
I have no idea :) But let's see
coursier gets its information about the amm application probably from https://github.com/coursier/apps/blob/master/apps/resources/ammonite.json
@kevinsjoberg you could cs launch com.lihaoyi:ammonite_3.1.0:2.5.3 -M ammonite.Main
not sure if there is a more idiomatic way
Florian Schmaus
@Flowdalic
another option would be to simply download and execute https://github.com/com-lihaoyi/Ammonite/releases/download/2.5.3/3.1-2.5.3
Kevin Sjöberg
@kevinsjoberg
That worked perfectly! :slight_smile:
Florian Schmaus
@Flowdalic
glad it worked, and welcome to Scala! I hope you enjoy the language, I sure do :)
Kevin Sjöberg
@kevinsjoberg
Thanks, I hopefully will. Btw, what determines what Coursier install by defualt? I did cs setup --jvm temurin:18 and it installed some apps by default. One was amm with the Scala 2 version.
Florian Schmaus
@Flowdalic
I've no idea where the default set of apps is defined nor why the apps are in there, but coursier, mill, Ammonite and probably os-lib seems to be stuff that you typically want to have in the Scala ecosystem
Kevin Sjöberg
@kevinsjoberg
Right. Thanks for the help. Truly appreciate it. :slight_smile:
eric-bzb
@eric-bzb
If I am using VS Code to edit and play with foo.worksheet.sc and I want to import bar.worksheet.sc into scope, is there a special syntax I am missing? import $file.bar.worksheet.sc does not seem to work because it tries to look inside a non-existant directory of ./bar/ Thank you in advance for your help! (edit, could not seem to get the backquotes to escape properly here, but hopefully you understand what I mean)
7 replies
Naftoli Gugenheim
@nafg
Thoughts on an Ammonite answer to xonsh?
It's a shell that's a superset of python syntax to allow doing shell things as easy as bash
Kostas Kougios
@kostaskougios

hi all, I am having an issue with ammonite :

Welcome to the Ammonite Repl 2.5.4 (Scala 2.13.8 Java 11.0.15)

I have created a jar using mill assembly. The jar seems fine and I can run an App via java -cp ..myjar.. my.class .
But I also have a script that imports the jar:

import $cp.lib.`out.jar`

(my jar is under lib/out.jar)

But when I execute my script I get :

amm sampledata.sc
....
java.io.IOException: Error accessing /Users/kkougios/projects/query/dist/query/lib/out.jar
  scala.reflect.io.FileZipArchive.scala$reflect$io$FileZipArchive$$openZipFile(ZipArchive.scala:194)
....
java.util.zip.ZipException: invalid CEN header (bad signature)
  java.util.zip.ZipFile$Source.zerror(ZipFile.java:1607)
  java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1557)
  java.util.zip.ZipFile$Source.<init>(ZipFile.java:1308)
  java.util.zip.ZipFile$Source.get(ZipFile.java:1271)

Since java reads fine my jar when I do java -cp ...myjar ... , why ammonite can't open it?
(btw this used to work with older versions of ammonite and mill, I am not sure why it is broken now)

ben
@ben:matrix.iofel.me
[m]
is %% replaced with os.proc(...).call?
discobaba
@uncleweirdo_twitter
Is there a way to get the path of the script that is running? (Other than bash trickery) I saw discussion about it but haven't discovered the incantation.
discobaba
@uncleweirdo_twitter
I just downloaded amm 2.5.4 for 2.13 and 3.1 and ran the same trivial script with each. (> amm rand.sc epd 100) 2.13 worked fine, 3.1 says 'Script rand.sc does not take arguments: "epd" "100"'. Why does that make sense?
discobaba
@uncleweirdo_twitter

Or simplifying further, the following script works with amm 2.5.4 with scala 2.13.8 but not scala 3.1.2:

@main def main(): Unit = println("Hello, world")

Although it does compile ... Does amm actually work with scala 3?

Lorenzo Gabriele
@lolgab
@uncleweirdo_twitter Ammonite scripts have already a generated main method, you don't need to write a main. You can directly put your code in the .sc file like:
println("Hello world")
There is an issue with Scala 3 and the included libraries, like upickle, that use the 2.13 artifacts (which are not compatible with Scala 3 because of macros).
You can workaround this problem by running ammonite with --thin and then add the libraries yourself with
import $ivy.`com.lihaoyi::upickle:2.0.0`
discobaba
@uncleweirdo_twitter
Cool, thanks. And use mainargs library, I guess? It claims to be scala 3 friendly, I see.
Lorenzo Gabriele
@lolgab
It suffers from the same problems as upickle so it needs --thin for now, but it should work on Scala 3 as well
Actually mainargs is included also in --thin :( so it will not work in Scala 3
discobaba
@uncleweirdo_twitter
Legions of scala fans are anxiously waiting ;-)
discobaba
@uncleweirdo_twitter
Well, I was originally using the "main" method because of a need to pass arguments and just kind of simplified them away to illustrate the failure I was getting. How does one pass arguments to a scala 3 amm script? Or better, where are the examples?
Lorenzo Gabriele
@lolgab
I think this is not supported on Scala 3 at all yet
You can try in scala-cli
discobaba
@uncleweirdo_twitter
Yeah, that works. Thanks
bblfish
@bblfish:matrix.org
[m]
I try using source but I get the error
@ source(new java.util.ArrayList())
cmd5.sc:1: could not find implicit value for parameter pprinter: pprint.PPrinter
val res5 = source(new java.util.ArrayList())
                 ^
Compilation Failed
I am using Ammonite Repl 2.5.4 (Scala 2.13.8 Java 18.0.1.1)
I deleted my old .ammonite directory
Saqib Saleem
@saqib-trywe
Hi - I’ve come back to using ammonite after a fairly longtime and ls! no longer works. Infact other nice syntax like |? also no longer works. Has this been removed?
4 replies
ben
@ben:matrix.iofel.me
[m]
Thats a good question, how do you use grep with the new os lib?
Li Haoyi
@lihaoyi
it was changed when we dropped ammonite-ops in favor of os-lib
you can probably copy the old code and make it work, but i don't personally use it and we stopped supporting jt
ben
@ben:matrix.iofel.me
[m]
grep is still there by default, how would you use it now?
Li Haoyi
@lihaoyi
i don't haha, probably should have removed it as well
Jakob Vad Nielsen
@lazee
Hi. This has probably been answered many times before...Is it possible to get IntelliJ to import external dependencies these days for Ammonite scripts? I have tried to follow guides like https://www.baeldung.com/scala/ammonite-scripting, but no matter what I do, cats-effect and other packages are not imported. Any tips or recommendations for other IDEs where Ammonite scripting works like a charm ?
image.png
Hard to code when everything looks like this. I have tried the $ivy.{} way of importing packages, but IntelliJ still doesn't import the packages.
ben
@ben:matrix.iofel.me
[m]
$ivy works for me in intellij
Sometimes i have to use Option + enter and ask it to download the library
Florian Schmaus
@Flowdalic

I get

java.lang.NoSuchMethodError: 'void geny.Writable.$init$(geny.Writable)'
  upickle.Api$$anon$1.<init>(Api.scala:94)
  upickle.Api.stream(Api.scala:94)
  upickle.Api.stream$(Api.scala:92)
  upickle.default$.stream(Api.scala:157)
  ammonite.runtime.Storage$Folder$$anon$33.update(Storage.scala:220)

when trying to embed ammonite in a Scala 3.1.2 project

Ok, manually adding ivy"com.lihaoyi::upickle:2.0.0", to the deps fixes it
uh, and I also run into com-lihaoyi/Ammonite#1250