Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 03 20:03
    fiadliel closed #2283
  • Dec 03 20:03
    fiadliel commented #2283
  • Dec 03 13:45
    scala-steward closed #2279
  • Dec 03 13:45
    scala-steward commented #2279
  • Dec 03 13:45
    scala-steward opened #2284
  • Dec 03 11:45
    fiadliel opened #2283
  • Dec 01 13:33
    mavericksy closed #2282
  • Dec 01 13:33
    mavericksy commented #2282
  • Dec 01 13:14
    alexarchambault commented #2282
  • Dec 01 13:06
    alexarchambault commented #2282
  • Dec 01 12:43
    mavericksy opened #2282
  • Nov 30 21:10
    varungandhi-src opened #2281
  • Nov 30 16:53
    juhp edited #2280
  • Nov 30 16:53
    juhp opened #2280
  • Nov 29 20:12
    scala-steward opened #2279
  • Nov 29 17:31
    kpodsiad commented #2278
  • Nov 29 17:26
    kpodsiad synchronize #2278
  • Nov 29 17:26
    kpodsiad synchronize #2278
  • Nov 29 14:43
    kpodsiad opened #2278
  • Nov 28 15:11
    scala-steward closed #2187
Hanns Holger Rutz
@Sciss
I'm working on a desktop application launcher, using Coursier as a library. Works great so far.
1 reply
Hanns Holger Rutz
@Sciss

Here is a solution for obtaining the pom file that works with maven repositories - I basically peeked into MavenRepository:

      val cacheArt  = cache.FileCache[Task](cfg.artDir)

      val appDepPOM = appDep.withTransitive(false)
      val resolvePOM = Resolve(cacheResolve).addDependencies(appDepPOM).withRepositories(repos)
      resolvePOM.future().foreach { resolution =>
        println("---- RESOLVED ARTIFACTS ----")
        resolution.artifacts().foreach { a =>
          println(s"url = ${a.url}") // ; extra = ${a.extra}")
        }
        println("----")
        val artifacts = Artifacts(cacheArt).withResolution(resolution).addTransformArtifacts { sq =>
          sq.map { case (dependency, _ /*pub*/, art0) =>
            // cf. MavenRepository - metadataArtifact
            val metadataPub = Publication(dependency.module.name.value, Type.pom, Extension.pom, Classifier.empty)
            val metadataURL = {
              val u = art0.url
              assert (u.endsWith(".jar"))
              s"${u.substring(0, u.length - 4)}.${metadataPub.ext.value}"
            }
            val metadataArtifact  =
              Artifact(
                metadataURL,
                Map.empty,
                Map.empty,
                changing = false, // XXX TODO what is this?,
                optional = true,
                authentication = art0.authentication
              ).withDefaultChecksums.withDefaultSignature

            (dependency, metadataPub, metadataArtifact)
          }
        }
        val fetch = new Fetch(resolvePOM, artifacts, None)
        fetch.futureResult().foreach { res =>
          println("---- FETCHED ARTIFACTS ----")
          res.artifacts.foreach { case (_, f) =>
            println(f)
          }
          println("----")
        }
      }
---- RESOLVED ARTIFACTS ----
url = https://repo1.maven.org/maven2/de/sciss/mellite-app_2.13/2.48.0/mellite-app_2.13-2.48.0.jar
----
---- FETCHED ARTIFACTS ----
/home/hhrutz/.local/share/mellite/default/cs/https/repo1.maven.org/maven2/de/sciss/mellite-app_2.13/2.48.0/mellite-app_2.13-2.48.0.pom
----

is there a public API to achieve this? Also, this fails for local ivy repository, because the .pom is in a different directory. How do I get the Repository belonging to each artifact in a Resolution?

4 replies
Guillaume Galy
@guilgaly
Hello,
I recently tried using Coursier's cs tool to setup my Scala dev env (JDK, SBT, etc.), but I found an issue when installing SBT this way. I have a situation where SBT gets executed with the -batch flag; this flag is correctly recognized by SBT installed via Homebrew, but not by SBT installed via Coursier.
  • I think the difference is because the sbt command installed by cs is actually from coursier/sbt-runner while the one installed by Homebrew probably comes from sbt/sbt-launcher-package; does that sound right?
  • if so, should that be considered a bug in sbt-runner?
    (I have to say that it's quite confusing that the same option might be either accepted or rejected depending on how you install SBT... 😅)
5 replies
nafg
@naftoligug:matrix.org
[m]
Is this supposed to work? cs launch scala3-compiler:3.0.0-RC1
2 replies
nafg
@naftoligug:matrix.org
[m]
Hi, how can I do the equivalent of cs launch from code, capturing stdout and stderr?
1 reply
Chris Kipp
@ckipp:matrix.org
[m]
I'm having a hard time understanding why this doesn't work
cs complete -r sonatype:snapshots org.scalameta:metals_2.12:
4 replies
this still just prints out all of the Metals stable versions and doesn't capture what I'd expect it to from here: https://oss.sonatype.org/content/repositories/snapshots/org/scalameta/metals_2.12/maven-metadata.xml
I believe I even asked this before, but I've never successfully been able to list out the actual snapshot versions of Metals that exist here, are able to be pulled, but never show up in complete
any idea how to see these or what I'm doing wrong here?
Simon Parten
@Quafadas
Can anyone see anything I'm doing obviously wrong here?
simon@Simons-Mac-mini formula-example % coursier launch ammonite
Loading...
Welcome to the Ammonite Repl 2.3.8-56-2be2b739 (Scala 2.13.5 Java 15.0.2)
@ val s = "1.0" 
scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
  scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:24)
  scala.reflect.internal.Mirrors$RootsBase.$anonfun$getModuleOrClass$6(Mirrors.scala:66)
9 replies
ritschwumm
@ritschwumm
pray tell - is there a way to print each and every http request coursier issues from inside sbt (preferrable 1.4.9, i have some other issue with 1.5.0 i don't want to deal with right now)?
i have interesting issues with a locally hosted artifactory which gives me quite unexpected 403 forbidden responses, and i need more input to think about.
2 replies
ritschwumm
@ritschwumm
another question: am i right in guessing that OkHttpDownload is the one used in sbt by default, and it does send basic authentication headers right from the beginning, without waiting for a status 401 first? if that's the case, it would be worth a comment in sbt/sbt#5556
2 replies
Parth
@thepartyshukla_twitter

Hello Folks, I am currently migrating a project from sbt 1.1 to sbt 1.4, and upon compilation, I get this issue.

[error] Modules were resolved with conflicting cross-version suffixes in ProjectRef(uri("file:/home/parthshukla/IdeaProjects/project/"), "api"):
[error]    com.typesafe.akka:akka-actor _2.12, _2.11
[error]    com.typesafe.akka:akka-protobuf _2.12, _2.11
[error]    org.scala-lang.modules:scala-java8-compat _2.12, _2.11
[error]    com.typesafe.akka:akka-slf4j _2.12, _2.11
[error] stack trace is suppressed; run last api / update for the full output
[error] (api / update) Conflicting cross-version suffixes in: com.typesafe.akka:akka-actor, com.typesafe.akka:akka-protobuf, org.scala-lang.modules:scala-java8-compat, com.typesafe.akka:akka-slf4j
[error] (coreLib / Compile / compileIncremental) javac returned non-zero exit code
[error] Total time: 24 s, completed Apr 15, 2021, 10:24:20 PM

This is how the dependencies in my build.sbt are declared

libraryDependencies ++= Seq(
    "de.organisation" % "module-test" % organisationVersion % Test excludeAll(
      ExclusionRule("junit", "junit"),
      ExclusionRule(organization = "com.typesafe.akka"),
      ExclusionRule(organization = "org.scala-lang.modules"),
      ExclusionRule(organization = "org.jboss.spec.javax.ws.rs"),
      ExclusionRule(organization = "org.jboss.spec.javax.servlet"),
      ExclusionRule(organization = "org.jboss.spec.javax.annotation"),
      ExclusionRule(organization = "javax.activation"),
      ExclusionRule(organization = "net.jcip"),
      ExclusionRule(organization = "org.jboss.logging"),
      ExclusionRule(organization = "com.sun.xml.bind"),
      ExclusionRule(organization = "com.sun.mail"),
      ExclusionRule(organization = "org.apache.james")
    ),
    "org.easytesting" % "fest-assert" % "1.4" % Test,
    "junit" % "junit" % "4.12" % Test,
    "pl.pragmatists" % "JUnitParams" % "1.1.1" % Test,
    "org.mockito" % "mockito-all" % "1.9.5" % Test,
    "nl.jqno.equalsverifier" % "equalsverifier" % "3.1.7" % Test
  )
)

When I disable coursier, the project compiles successfully and therefore I believe the issue is coming from a coursier incompatability. Can someone please help? I've been beating my head against this for a while now

Rob Norris
@tpolecat
It seems that the Coursier launcher for sbt doesn't work with 1.5.0 … it's not clear to me who is in charge of keeping it updated, or really whether it should exist at all given the complexity of the standard launcher script. It seems to me that resolving this is a blocker for Coursier becoming the standard way to manage Scala tooling. Maybe this would be a good Scala Center project, I don't know.
Does anyone have any better-formed thoughts about this?
mushtaq
@mushtaq
@tpolecat try cs uninstall sbt followed by sbt install sbt. It worked for someone here.
Rob Norris
@tpolecat
Sorry, I meant csbt
Ali Salim Rashid
@arashi01

Hi all. Anyone know if it is possible to get the version number of an app that would be resolved by cs install or cs bootstrap?

For example, for apps declared with latest.stable version in a channel such as 'scala' from the 'core' channel, is there any way to get the version that would be fetched by cs bootstrap scala?

Vlad Patryshev
@vpatryshev
Hope I'm not asking a dumb question here.
I have some code that I publish locally via sbt publishLocal; seems like it only stores it to .ivy2, but we use Coursier, so am I out of luck? Or there is a magic trick to either make Coursier view what's in .ivy2?
Vlad Patryshev
@vpatryshev:matrix.org
[m]
Oh, my previous message... just ignore it; I don't see how to remove it.
phendric
@phendric

Hi all. Question: when I try to install coursier in a new WSL2 instance of Ubuntu 20.04, I get an error that Java is not found:

$ curl -L https:/git.io/coursier-cli -o cs
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   135    0   135    0     0    424      0 --:--:-- --:--:-- --:--:--  1646
100 42577  100 42577    0     0  85495      0 --:--:-- --:--:-- --:--:-- 85495
$ chmod +x cs
$ ./cs install cs
./cs: 25: exec: java: not found

Do I have the wrong link? Or is something else going on here?

Roberto Tyley
@rtyley
Hello all, I'm curious as to how 'complete' (https://get-coursier.io/docs/cli-overview.html#complete) does what it does, because it seems incredible (how does it work out all the artifacts for a group?! Where is the Maven data for that!?). I was trying to dig through the code (looking at eg https://github.com/coursier/coursier/blob/382250d4f26b4728400a0546088e27ca0f129e8b/modules/core/shared/src/main/scala/coursier/maven/MavenComplete.scala#L16 ) but was slightly hamstrung because IntelliJ fails to import the sbt project (I don't know if there's any special guidance on etting IntelliJ to do this, couldn't see any in https://get-coursier.io/docs/dev-contributing ).
Roberto Tyley
@rtyley
Oh wow - to answer my own question about "how does it work out all the artifacts for a group?" (specifically I was interested in Maven Central) - Coursier parses it (https://github.com/coursier/coursier/blob/382250d4f2/modules/util/jvm/src/main/scala/coursier/util/WebPageCompatibility.scala#L9-L14) from raw HTML directory listings, like eg https://repo1.maven.org/maven2/org/typelevel/ . Those HTML directory listings were the best source of that information I'd been able to find (possibly the only source, apart from https://search.maven.org/solrsearch/select) but I was still a bit surprised that they are the best source of that information. Those HTML pages haven't changed format for a long time, but I'm assuming they aren't a formal API, or are they? I wonder if aether/Maven Artifact Resolver Provider do this. I mean, this approach works fantastically well, I'm just slightly unnerved.
Chris Kipp
@ckipp:matrix.org
[m]
If I'm not mistaken the html listing page is actually a backup that coursier uses if it's unable to locate the maven-metadata.xml file for a project
most of the time I believe the full version information is simply parsed from the maven-metadata file both for the complete and resolve functionality
Roberto Tyley
@rtyley
That makes sense! I guess it can definitely refer to maven-metadata.xml when an artifact coordinate is specified (eg org.typelevel:cats-core_2.13) which most be the most common kind of question it faces, but there's no usable maven-metadata.xml at the group level (eg https://repo1.maven.org/maven2/org/typelevel/maven-metadata.xml doesn't exist) - so if you want to find all the artifacts that live under a group id (eg org.typelevel) then there's no choice but to parse the HTML out of the directory listing page. It's a much rarer question though - I'm currently interested in it, but I guess it's not going to be an essential part of eg resolving all the dependencies of build!
Bjorn Regnell
@bjornregnell
can cs show me which versions are installed of for example scala and scala3-repl ?
cs list just gives me the names not the versions...
Bjorn Regnell
@bjornregnell
@phendric I think you should use https://git.io/coursier-cli-linux or the thing from https://alexarchambault.github.io/posts/2020-09-21-cs-setup.html#managing-applications that tries to judge which os you are on, but not sure how that works on WSL2/Ubuntu20.04: curl -fLo cs https://git.io/coursier-cli-"$(uname | tr LD ld)" so perhaps safer to just use curl -fLo cs https://git.io/coursier-cli-linux
Ghost
@ghost~5e342765d73408ce4fd850b1
I am having trouble with using the FileCredentials class to set auth for a repo (it does not like my Windows path to a credentials file), so I thought I'd use the method described in the documentation instead, but no file location for the credentials.properties file is given for Windows. I've tried putting it under users/username/.config etc but no dice thus far. I'm using whatever version of coursier that comes with the Scala Metals plugin on VSCode
I should be able to access the properties using sys.props.get if they're properly loaded yeah?
Parth
@thepartyshukla_twitter
Hi guys, I am facing an error trying to run the project after it compiles successfully
[error] java.lang.NoClassDefFoundError: com/google/common/hash/Hashing
[error]     at io.methvin.watcher.PathUtils.<clinit>(PathUtils.java:36)
[error]     at io.methvin.watcher.DirectoryWatcher.<init>(DirectoryWatcher.java:78)
[error]     at play.dev.filewatch.DefaultFileWatchService.watch(DefaultFileWatchService.scala:36)
[error]     at play.dev.filewatch.FileWatchService$$anon$1.watch(FileWatchService.scala:87)
[error]     at play.runsupport.Reloader.<init>(Reloader.scala:359)
[error]     at play.runsupport.Reloader$.reloader$lzycompute$1(Reloader.scala:220)
[error]     at play.runsupport.Reloader$.play$runsupport$Reloader$$reloader$1(Reloader.scala:220)
[error]     at play.runsupport.Reloader$.startDevMode(Reloader.scala:230)
[error]     at play.sbt.run.PlayRun$.devModeServer$lzycompute$1(PlayRun.scala:95)
[error]     at play.sbt.run.PlayRun$.devModeServer$1(PlayRun.scala:79)
[error]     at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:102)
[error]     at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:65)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] Caused by: java.lang.ClassNotFoundException: com.google.common.hash.Hashing
[error]     at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[error]     at io.methvin.watcher.PathUtils.<clinit>(PathUtils.java:36)
[error]     at io.methvin.watcher.DirectoryWatcher.<init>(DirectoryWatcher.java:78)
[error]     at play.dev.filewatch.DefaultFileWatchService.watch(DefaultFileWatchService.scala:36)
[error]     at play.dev.filewatch.FileWatchService$$anon$1.watch(FileWatchService.scala:87)
[error]     at play.runsupport.Reloader.<init>(Reloader.scala:359)
[error]     at play.runsupport.Reloader$.reloader$lzycompute$1(Reloader.scala:220)
[error]     at play.runsupport.Reloader$.play$runsupport$Reloader$$reloader$1(Reloader.scala:220)
[error]     at play.runsupport.Reloader$.startDevMode(Reloader.scala:230)
[error]     at play.sbt.run.PlayRun$.devModeServer$lzycompute$1(PlayRun.scala:95)
[error]     at play.sbt.run.PlayRun$.devModeServer$1(PlayRun.scala:79)
[error]     at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:102)
[error]     at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:65)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] stack trace is suppressed; run last Compile / run for the full output
[error] (Compile / run) java.lang.NoClassDefFoundError: com/google/common/hash/Hashing
[error] Total time: 2 s, completed May 19, 2021 6:17:49 PM
It used to run fine earlier on some instances, and this issue seems to have started coming out of the blue
Yadu Krishnan
@yadavan88
Hey, I am trying to install a custom application using cs. I published it to local artifactory and able to fetch it using the cs fetch -r. I am trying to create a bootstrap using -r argument. But while running the bootstrapped file, I am getting the permission error for it. Server returned HTTP response code: 401Could anyone help me to run it?
That is I am not able to understand how to pass the credentials .
1 reply
phendric
@phendric
@bjornregnell curl -fLo cs https://git.io/coursier-cli-linux works under WSL2/Ubuntu20.04. Looking back at my post, I realized I was missing a "/" after the https, and I didn't include the linux specific portion of the file!
Yadu Krishnan
@yadavan88
I created my own and app and published to a local repository. I also created a descriptor. Everything works fine if I give the exact version in the descriptor. But if I use latest.release or latest.stable, it is not getting resolved. Do I need to do something for that? Thanks in advance.
Piotr Gabara
@pgabara

Hi, I use sbt through coursier and when I try to run it with '-mem' parameter I got an error.

Here is what I get:

[error] Expected symbol
[error] Not a valid command: -
[error] Expected end of input.
[error] Expected '--'
[error] Expected 'debug'
[error] Expected 'info'
[error] Expected 'warn'
[error] Expected 'error'
[error] Expected 'addPluginSbtFile'
[error] -mem
[error]  ^

Do you have any idea how to fix it?

Raul Rodriguez
@raul782
Trying to update Coursier to test scala3 was very frustrating, I tried cs install cs and got the same error. I don't understand why this keeps failing as this is the recommended way to install scala3. I'm going back to sbt for now. Is somebody able to help:
cs update cs
Exception in thread "main" java.lang.Exception: Reading /Users/raul/Library/Application Support/Coursier/bin/cs
    at coursier.install.InfoFile$.readSource(InfoFile.scala:64)
    at coursier.install.InstallDir.$anonfun$maybeUpdate$3(InstallDir.scala:403)
    at coursier.install.InstallDir.$anonfun$maybeUpdate$3$adapted(InstallDir.scala:396)
    at coursier.util.Task$.$anonfun$flatMap$extension$1(Task.scala:14)
    at coursier.util.Task$.$anonfun$flatMap$extension$1$adapted(Task.scala:14)
    at coursier.util.Task$.wrap(Task.scala:84)
    at coursier.util.Task$.$anonfun$flatMap$2(Task.scala:14)
    at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.lang.Thread.run(Thread.java:834)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: java.util.zip.ZipException: zip END header not found
    at java.util.zip.ZipFile$Source.zerror(ZipFile.java:1535)
    at java.util.zip.ZipFile$Source.findEND(ZipFile.java:1436)
    at java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1443)
    at java.util.zip.ZipFile$Source.<init>(ZipFile.java:1274)
    at java.util.zip.ZipFile$Source.get(ZipFile.java:1237)
    at java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:727)
    at java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:55)
    at java.util.zip.ZipFile.<init>(ZipFile.java:247)
    at java.util.zip.ZipFile.<init>(ZipFile.java:177)
    at java.util.zip.ZipFile.<init>(ZipFile.java:191)
    at coursier.install.InfoFile$.readSource(InfoFile.scala:45)
    ... 14 more
Btw, this happened in MacOS Catalina
Bjorn Regnell
@bjornregnell
@raul782 As a fallback you can just download https://github.com/lampepfl/dotty/releases/download/3.0.0/scala3-3.0.0.zip and put the extracted files in e.g. ~/scala3 and put the ~/scala3/bin on your path and you are ready to go. But perhaps it does not work if the above error is a symptom of problems with Java installation, then I'd recommend you to install JDK 11 from here https://adoptopenjdk.net/
Russ White
@russwyte
I am trying to install aarch64 jvm on my mac mini m1 - any tips on how to do that with coursier?
I see it exists in the index - but I don't know how to indicate that it should be installed:
https://github.com/shyiko/jabba/blob/11843e0b352868b41200abc445e50143c2b4a877/index.json#L1254
cs java --jvm zulu:16 --setup installs the x64 version
Eric K Richardson
@ekrich
I would go with 11 or 8 though if you are doing Scala type stuff.
Hanns Holger Rutz
@Sciss
if I want to run Versions() without any cache checks, what's the best idea? FileCache(...).withTtl(0.minutes) is that something reasonable, or ... ?
Bjorn Regnell
@bjornregnell
When I read the docs here https://get-coursier.io/docs/cli-installation I get the impression that coursier should fix my path. But when I follow the instructions it only prints a message that I should do it myself. Can coursier patch my path? If not then that page should perhaps be clarified so it is obvious that I need to do this myself. (I'm currently considering using cs for my beginner programmer students and unfortunately I think the instructions are a bit intimidating for a beginner so if we are going use cs I need to give them something easier to follow that does not assume any deeper knowledge of cmd/bash/terminal/console/powershell... etc)
image.png
Bjorn Regnell
@bjornregnell
Does anyone know how cs can install a scala3 runner? WIth the instructions here https://www.scala-lang.org/download/scala3.html you get scala3-compile and scala3-repl on your path but not any scala3 runner on your path to run your compiled programs. So how to run your programs compiled with cs scala3-compiler?
Bjorn Regnell
@bjornregnell
Damian Reeves
@DamianReeves
Hey, the coursier command line doesn’t seem to be picking up things like HTTP_PROXY I know I can pass in these options using the -J-D command line options but is there a file that both the coursier command line and coursier as a library uses to load these settings?