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
Jesse Atkinson
@jsatk
@lihaoyi-databricks is there really no way to use the ammonite + scala version in "Hands-On Scala" together right now?
Eric K Richardson
@ekrich
Have you seen this - com-lihaoyi/Ammonite#1093
Eric K Richardson
@ekrich
cc @jsatk
Li Haoyi
@lihaoyi
I honestly don't know anything about cats, and havent tested it with the instructions in the book. You should be able to work through the entire book without cats
you're free to try to get it working, but it's not the common path, and you need to know that you'll need to sort through any issues that arise
looks to me like you have some wrong scala version on the classpath somewhere
that's likely a result of trying to get both scala 212 and 213 working
might be a bug in Ammonite, but an easy workaround is to jusy stick with 2.13 wrt the book
213 is the common path; you can try other things later
Eric K Richardson
@ekrich
I agree, you should definitely use 2.13 unless you can't. No need to learn older stuff unless you have to.
Chris Kipp
@ckipp:matrix.org
[m]
I don't think this is necessarily a cats thing that @jsatk is bringing up. Since the added support for Scala 3 there has been some major regressions. For example when using the latest version with 2.13, you can't import Try, stuff like that com-lihaoyi/Ammonite#1182
so even if you use 2.13 without Cats, be cautious of some of these errors that are popping up
Eric K Richardson
@ekrich
Oh yes, that is a bummer.
Jesse Atkinson
@jsatk
Yeah. I still haven't been able to get it to load cats on start up using coursier. I think for now I'll just do the book w/ my predef.sc commented out and launching ammonite via cs
Jesse Atkinson
@jsatk
@lihaoyi is the recommended way to launch ammonite for scala 2.13 to use coursier?
Li Haoyi
@lihaoyi
no, the recommended way is what it says in chapter 2
if you want to follow along with the book, follow along with the book
Li Haoyi
@lihaoyi
if you want to fiddle with DIY build tooling, that's fine too, just don't complain when you end up fiddling with DIY build tooling :)
Oron Port
@soronpo
:)
Jesse Atkinson
@jsatk
Finally figured out a simple solution. cs launch ammonite --scala 2.13. I was previously attempting the more verbose cs launch com.lihaoyi:ammonite_2.13.4:2.1.4 -M ammonite.Main which puked.
The former (shorter and more readable) seems to work great. Both for simply firing up ammonite with a certain scala version and also using my predef.sc file.
discobaba
@uncleweirdo_twitter

I have a script that works or not depending how it is called and where it lives. It isn't trying to be cute abount the directory it is in. ~/scripts/update_rfids.sc works fine. If I save it as /tmp/.tballard/scripts/update_rfids.sc and am in that directory, ./update_rfids.sc succeeds, but /tmp/.tballard/scripts/update_rfids.sc fails. Here's the error:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
    at java.base/java.lang.String.charAt(String.java:693)
    at ammonite.util.Name.<init>(Model.scala:50)
    at ammonite.interp.AmmonitePlugin$.$anonfun$apply$10(AmmonitePlugin.scala:198)
    at scala.collection.ArrayOps$.map$extension(ArrayOps.scala:924)
    at ammonite.interp.AmmonitePlugin$.$anonfun$apply$9(AmmonitePlugin.scala:198)
    at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:169)
    at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:165)
    at scala.collection.immutable.List.foldLeft(List.scala:79)
    at ammonite.interp.AmmonitePlugin$.apply(AmmonitePlugin.scala:164)
    at ammonite.interp.AmmonitePlugin$$anon$1$$anon$2.apply(AmmonitePlugin.scala:36)
    at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:452)
    at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:397)
    at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1506)
    at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1490)
    at scala.tools.nsc.Global$Run.compileSources(Global.scala:1482)

I can provide more stack if it helps.

discobaba
@uncleweirdo_twitter
In the good old days, running the script with no args displayed the "main" methods with arguments. Nice. Sorry to see it go. (Although it would have been nice to be able to avoid advertising one)
discobaba
@uncleweirdo_twitter
apparently raw is the empty string ...
case class Name(raw: String){
  assert(
    NameTransformer.decode(raw) == raw,
    "Name() must be created with un-encoded text"
  )
  assert(raw.charAt(0) != '`', "Cannot create already-backticked identifiers")
  override def toString = s"Name($backticked)"
  def encoded = NameTransformer.encode(raw)
  def backticked = Name.backtickWrap(raw)
}
discobaba
@uncleweirdo_twitter
This amm bug showed up when I created an object Dev and then imported some fields from it allowing accessing Dev.Db as Db, etc. The work-around was removing the imports and using Dev.Db, etc. Maybe just approaching rock-solid;-)
discobaba
@uncleweirdo_twitter

Looking at the ammonite documentation for the new @arg(doc = "This explains what the function does")
feature it says that by adding it to a function the user message:

|  -i <int>
|  -s <str>

is transformed to:

|  -i <int>
|  -s <str>

That appears to be accurate, but doesn't sound like the result one would hope for;-)

James Kyle
@jameskyle

Hey, everyone. In my environment I'm getting a method not found error from protobuf: java.lang.NoSuchMethodError: com.google.protobuf.descriptor.FileDescriptorProto$.parseFrom(. When I checked the location of the class, it's being loaded from the amm binary. I think it's due to a conflict between an older protobuf library bundled with ammonite and the protobuf that my runtime libraries are depending on.

@ import  com.google.protobuf.descriptor.FileDescriptorProto
import  com.google.protobuf.descriptor.FileDescriptorProto

@ val klass = classOf[FileDescriptorProto]
klass: Class[FileDescriptorProto] = class com.google.protobuf.descriptor.FileDescriptorProto

@ klass.getResource('/' + klass.getName().replace('.', '/') + ".class")
res5: java.net.URL = jar:file:/usr/local/bin/amm!/com/google/protobuf/descriptor/FileDescriptorProto.class

I think this issue might be related (com-lihaoyi/Ammonite#1177), however when I try the suggested --thin flag I get errors for missing sun.reflect dependencies java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl

James Kyle
@jameskyle
ping
Paul Bryan
@locke8
Hi all, can anyone tell me if Ammonite supports development of Scala 3?
I ask because this code: "opaque type Command = String", gives me an error [; expected but type found] if I run as Ammonite script but works within a worksheet. I'm using latest version of Metals.
Stefano Sgorlon
@gokyo
I'd like to import some extra .class files (located in an external folder) using interp.load.cp or $cp. Do you have a working example?
Tobias Roeser
@lefou
import $cp.external
eric-bzb
@eric-bzb
is there an ammonite equivalent to mill -i ... ? For example, I've noticed that I need to pass -i to mill -i main.run in order for a (cats-effect) readLine to actually work. Without the -i it just hangs when it gets to readLine. I'm wondering if anyone has had the same issue with ammonite?
Tobias Roeser
@lefou
@eric-bzb That's because mill uses a client-server-setup to speed up repetitiv build tasks. This should not needed in ammonite, as ammonite runs in a single process and has therefore access to the system input. It should be always interactive.
eric-bzb
@eric-bzb

@lefou ok, thanks. It is odd then that Ammonite seems to have trouble running things like amm Example.sc where Example.sc contains:

//Example.sc
import $ivy.`org.typelevel::cats-effect:3.2.5`
import cats.effect.unsafe.implicits._ 
import cats.effect.IO 
val run = for {
  _ <- IO.println("Hello")
  _ <- IO.println("World")
  input <- IO.readLine
  _ <- IO.println(s"echo $input")
} yield ()
run.unsafeRunSync()

For me, it only prints "Hello" and then hangs.

and the oddity is that pasting the above directly into an already-running ammonite repl seems to instead work just fine... it's the command amm Example.sc that does not seem to work properly
Jesse Atkinson
@jsatk
I upgraded my repo to 2.12.14 but now I'm getting this error on compile. Any ideas? [error] Error downloading com.lihaoyi:ammonite-interp_2.12.14:1.8.2
Chris Kipp
@ckipp:matrix.org
[m]
that artifact doesn't exist @jsatk
it looks like for 2.12.14 the only version of ammonite-interp that are available are a bunch of snapshots
you can see this with
cs complete com.lihaoyi:ammonite-interp_2.12.14:
Jesse Atkinson
@jsatk
Ah. Thanks. I thought so but i was like "that can't be right".
So as it stands... if I want to upgrade from 2.12.12 to 2.12.14 I can't because Bloop plugin is required for Metals? I'd have to use intelliJ? :(
the bloop plugin is what I believes attempts to pull down ammonite.
when i compile
Chris Kipp
@ckipp:matrix.org
[m]
I don't think that should be the issues. Lots of Metals users use 2.12.14, so if that was the case would would have hit on that.
you should be able to use something like sbt whatDependsOn or even coursier resolve to see what is actually pulling that in
daravep
@daravep

Heya, I'm struggling a bit with multiple ammonite consoles running concurrently, attempting to concurrently modify the fs cache:

java.nio.file.FileAlreadyExistsException: /home/.../.ammonite/rt-11.0.11.jar
        at java.base/sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:573)
        at ...
        at io.github.retronym.java9rtexport.Export.rtAt(Export.java:105)
        at ammonite.util.Classpath$.classpath(Classpath.scala:76)
        at ammonite.compiler.CompilerLifecycleManager.init(CompilerLifecycleManager.scala:92)
        at

Is this not supported?

1 reply
discobaba
@uncleweirdo_twitter
Since the switch from "@doc" to "@arg(doc = ", I haven't understood how the doc for a main method is used by amm. The @doc behavior of displaying the description for all the main methods was nice.
Artem Egorkine
@arteme
Whatever happened to ammonite printing method signatures on tab completion (as mentioned in issue #26) is it hidden behind a flag or completely removed for some reason?
Artem Egorkine
@arteme
Why does source not work anymore in ammonite 2.4.0?
@ source(source) 
cmd0.sc:1: could not find implicit value for parameter pprinter: pprint.PPrinter
val res0 = source(source)
                 ^
Compilation Failed