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
Florian Schmaus
@Flowdalic
would be nice if that got fixed
Tobias Roeser
@lefou
@Flowdalic, could you open an issue, please?
I think building is still possible, but for (local) publishing, you need to override one target.
Tobias Roeser
@lefou
def millVersion, IIRC
Florian Schmaus
@Flowdalic
@lefou will do
I've a java.nio.file.Path instance that I'd like to pass to os.write(), somehow I expected the conversation to be implicit, but the compiler complains about a type mismatch
I somehow assume that I just miss some import or other magic
Li Haoyi
@lihaoyi
os.Path(...) for an absolute path, os.Path(..., os.pwd) if it's a relative path and you want it to be relative to your current working directory
Florian Schmaus
@Flowdalic
@lihaoyi so the idea is that the user has to explicitly perform the conversion, right?
no scala implicit magic invovled
Li Haoyi
@lihaoyi
basically yeah, because we are downcasting from "who knows what this YOLO" to "definitely a normalized canonicalized absolute path", so you need either pass in an explicit base directory to absolute-ize relative paths, or accept that relative paths will blow up with an exception. Neither of those would be great to do implicitly
Florian Schmaus
@Flowdalic
ahh, that sounds sensible
Florian Schmaus
@Flowdalic
@lihaoyi any idea why https://index.scala-lang.org/com-lihaoyi/os-lib does return "Not found"?
Li Haoyi
@lihaoyi
@alexarchambault I tagged version 2.4.0 to get a new stable version compatible with latest version of uPickle 1.4.0. I added Internal preparation for basic Scala 3 support to the changelog, but feel free to add more if you have anything you'd like to say
1 reply
bjenkinsgit
@bjenkinsgit
Trying to get Visual Studio code to work with Ammonite. I've got VS Code v 1.56.2 on Windows 10 and am trying to get a simple Scala worksheet working. I created a new Scala3 sbt project using "sbt new scala3/scala-cross.g8" to get started. build.sbt shows that it has set the default scalaVersion := 3.0.0. VS Code is giving me a "Error fetching Ammonite 2.3.8-58-aa8b2ab1 for Scala 2.13.6" (Source: Scala Metals). Any hints how to fix?
Chris Kipp
@ckipp:matrix.org
[m]
so in Metals you're a bit limited by the default versions that we have and a mismatch between those and the latest versions available in Ammonite. Typically we add support for a new Scala version pretty quickly before Ammonite has a chance to
in an ammonite script in Metals you can actually specify the exact version of Ammonite and Scala version with comments at the top of the file
since metals uses ammonite-runner under the hood https://github.com/alexarchambault/ammonite-runner
Florian Schmaus
@Flowdalic

switching my project to scala 3 results in

[error] -- [E007] Type Mismatch Error:
[error] 22 |      os.symlink(symlink, dir)
[error]    |                                           ^^^^^^^^^^^^^^^^^^^^^^
[error]    |Found:    (Context.this.dir : os.Path#ThisType#ThisType)
[error]    |Required: os.FilePath
[error]    |

I guess that's an issue with different handling of implicits in Scala 3. Anything I could do?

mvillafuertem
@mvillafuertem
Hi there, how add resolvers to a script?
import coursierapi.MavenRepository

interp.repositories() ++= Seq(
  MavenRepository.of("https://packages.atlassian.com/maven-public/")
)

import $ivy.`com.atlassian.browsers:atlassian-browsers-auto:3.1.0`

@main
def main(): Unit = println("Hello")
Failed to resolve ivy dependencies:Error downloading com.atlassian.browsers:atlassian-browsers-auto:3.1.0
  not found: /root/.ivy2/local/com.atlassian.browsers/atlassian-browsers-auto/3.1.0/ivys/ivy.xml
  not found: https://repo1.maven.org/maven2/com/atlassian/browsers/atlassian-browsers-auto/3.1.0/atlassian-browsers-auto-3.1.0.pom
Tobias Roeser
@lefou
@mvillafuertem You need to add a standalone @ line before the import.
mvillafuertem
@mvillafuertem
@lefou Thanks a lot!
Tushar Mathur
@tusharmath
Is there a way to reduce the noise from the compiler errors a bit eg: the path ammonite.$file.src.main.scala.response.Response_10. repeated everywhere in error, making it really difficult to read.
type mismatch;
 found   : ammonite.$file.src.main.scala.response.Response_10.UHttp[ammonite.$file.src.main.scala.response.Response_10.ChannelEvent[ammonite.$file.src.main.scala.response.Response_10.Request],ammonite.$file.src.main.scala.response.Response_10.ChannelOperation[ammonite.$file.src.main.scala.response.Response_10.Response]]
    (which expands to)  ammonite.$file.src.main.scala.response.Response_10.ChannelEvent[ammonite.$file.src.main.scala.response.Response_10.Request] => zio.ZIO[Any,Option[Nothing],ammonite.$file.src.main.scala.response.Response_10.ChannelOperation[ammonite.$file.src.main.scala.response.Response_10.Response]]
 required: ammonite.$file.src.main.scala.response.Response_10.Http[?,?,ammonite.$file.src.main.scala.response.Response_10.ChannelEvent[Any],ammonite.$file.src.main.scala.response.Response_10.ChannelOperation[Nothing]]
    (which expands to)  ammonite.$file.src.main.scala.response.Response_10.ChannelEvent[Any] => zio.ZIO[?,Option[?],ammonite.$file.src.main.scala.response.Response_10.ChannelOperation[Nothing]]
The useful parts are only β€”
type mismatch;
 found   : UHttp[ChannelEvent[Request],ChannelOperation[Response]]
    (which expands to)  ChannelEvent[Request] => zio.ZIO[Any,Option[Nothing],ChannelOperation[Response]]
 required: Http[?,?,ChannelEvent[Any],ChannelOperation[Nothing]]
    (which expands to)  ChannelEvent[Any] => zio.ZIO[?,Option[?],ChannelOperation[Nothing]]
mvillafuertem
@mvillafuertem
Hi there, how can I integrate mainargs with ammonite? I don't get any results... πŸ˜•

import $ivy.`com.lihaoyi::mainargs:0.2.1`

import mainargs.{main, arg, ParserForMethods, Flag}

@main
def run(@arg(short = 'f', doc = "String to print repeatedly")
        foo: String,
        @arg(name = "my-num", doc = "How many times to print string")
        myNum: Int = 2,
        @arg(doc = "Example flag, can be passed without any value to become true")
        bool: Flag) = {
  println(foo * myNum + " " + bool.value)
}

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)

$ amm args-test.sc

Compiling /root/args-test.sc
Kunal Herkal
@kunalherkal

Hi, I am trying to download artefacts for an ammonite script from our internal maven repository which needs authentication.

I have following solution which works, but the issue is I will have to commit username and password in our git repo which is not desirable.

import coursierapi.MavenRepository
import coursierapi.Credentials

val credentials = Credentials.of(username, password)
val privaterepo = MavenRepository.of("https://internal.repo.com/repository/releases").withCredentials(credentials)

interp.repositories.update(
  interp.repositories() ::: List(privaterepo)
)

@

Two possible solutions I am exploring are,

  1. Using property-file at a default location, but this doesn't work on my machine for some reason. It works when I use fetch command with coursier cli, so credentials file is in correct default location and in correct format. But with Ammonite script, somehow coursier doesn't use this property file.
  2. Using system environment variable, but I couldn't find any example of these.

Can someone help me, possibly with working example on how to approach this?

Artem Egorkine
@arteme
Using a property file seems like a good idea. How do you determine the default location for the property file?
You can also use system properties, like Option(System.getProperty("internal.repo.username")).getOrElse(throw new Error("Username not defined"))
Artem Egorkine
@arteme
The latter requires to stat ammonite using java -jar ... or a simple wrapper app
Kunal Herkal
@kunalherkal
@arteme thanks for your reply.
Regarding the default location for the property file, property-file section in coursier docs says this:
Credentials can be passed via property files too. By default, ~/.config/coursier/credentials.properties is read (~/Library/Application Support/Coursier/credentials.properties on OS X).
Oscar Vargas Torres
@oscarvarto
Hello, how could I translate the following
xrandr -d :0 -q | grep ' connected' | wc -l
to ammonite syntax? I am having trouble finding the correct way
Oscar Vargas Torres
@oscarvarto
Anyone else here having problems with autocompletion of variables defined during session? I have seen this in version ammonite repl 2.4.0. Seems related to com-lihaoyi/Ammonite#996
Oscar Vargas Torres
@oscarvarto
This is happening to me with version for Scala 2.12 and 2.13 also. I am using Linux, Java 11.0.11
Clinton Mead
@clintonmead

I'm getting a very bizarre issue combining Ammonite 3 with cats-effect. The following script hangs between printing "1" and "2":

#!/usr/bin/env amm

import $ivy.`org.typelevel::cats-effect:3.1.1`
import cats.effect.IO
import cats.effect.unsafe.IORuntime

def g() : IO[Unit] = IO(())

object HelloWorld {
  def f() : IO[Unit] = IO(())

  val blah : IO[Unit] = for {
    x <- f()
    _ <- IO(println("1"))
    y <- g()
    _ <- IO(println("2"))
  } yield ()
}

HelloWorld.blah.unsafeRunSync()(IORuntime.global)

It seems as though it hangs on call to the top level function g() but not the member function f(). Any idea what's happening here?

agateriver
@agateriver
why I got a dumb terminal in Win10 ?
PS C:\Users\Xie> amm
Loading...
Compiling C:\Users\Xie\.ammonite\predef.sc
Compiling C:\Users\Xie\.ammonite\predef.sc #2
7月 08, 2021 10:40:17 上午 org.jline.utils.Log logr
θ­¦ε‘Š: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Welcome to the Ammonite Repl 2.4.0 (Scala 2.13.6 Java 11.0.2)
martingd
@martingd

Writing a Ammonite script like this:

#!/usr/bin/env amm

//... imports, etc.

@main(doc = "one entrypoint")
def entryOne() = {
    ???
}

@main(doc = "another entrypoint")
def entryTwo() = {
    ???
}

Running it results in:

% ./test.sc 
Need to specify a sub command: entryOne, entryTwo

Is there a way to have Ammonite print a usage message including the doc from the @main annotation?

jeroentervoorde
@jeroentervoorde
Hi, i'm running ammonite (2.4.0) in thin mode ('amm --thin') to avoid a dependency problem with guava. That works but now i'm running into an issue that sun.misc.Unsafe does not exist. Is there some way i can load the jdk.unsupported module from my ammonite script?
LoranceChen
@LoranceChen
Hi, I'm use vscode+metals to wirte ammonite .sc files. But one sc file cannot recognize another one. does someone encounter same problem?
LoranceChen
@LoranceChen
Metals output: Request textDocument/completion failed. and first caused by Caused by: java.nio.file.NoSuchFileException: /mnt/d/project/testshell/.ammonite/scala-2.13.6/amm-2.4.0/File02/src/ammonite/$file/File02.scala. but currently under the File02.sc file.
LoranceChen
@LoranceChen
has post a issue to vscode_metal project on github. scalameta/metals-vscode#626
Jesse Atkinson
@jsatk
I'm on Ammonite 2.4.0. When I run amm it fails on start up with this error: "Failed to resolve ivy dependencies". My ~/.ammonite/predef.sc looks like this http://i.jsatk.us/FY5FlN
Any ideas?
Li Haoyi
@lihaoyi
@jsatk can you try separating it out into three different import $ivy statements? IIRC I've seen bugs with this sort of multi-import in the past
Jesse Atkinson
@jsatk
Will try @lihaoyi . To be transparent. I'm very ignorant of ivy. Do I need to ... set up an credentials?
Jesse Atkinson
@jsatk
same error @lihaoyi