scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Report warnings if not sources are found and sent to the user

Open tgodzik opened this issue 1 year ago • 4 comments

Version(s) Scala CLI 1.5.4, but it doesn't happen reliably.

Describe the bug dependencySources request is met with an empty response

To Reproduce Try to start metals on a simple scripts as described in https://github.com/scalameta/metals/issues/6900

Expected behaviour We should report a warning in that case or ideally also retry fetching sources. (if that is a Bloop/Scala CLI race we might need to add more info to that warning)

tgodzik avatar Dec 04 '24 10:12 tgodzik

@Gedochao, I'll take a look at this.

kasiaMarek avatar Feb 26 '25 12:02 kasiaMarek

Here's what seems to be happening.

Running scala setup-ide . results in .bsp/scala.json args: scala-cli --cli-default-scala-version 3.x.x --repository file://.../maven2 --prog-name scala bsp .... I think the issue is that file://.../maven2 contains jars for Scala 3.x.x but it doesn't contain source jars.

You can see in the bloop configuration files, that sources for scala3-library_3 and scala-library are missing but present for other dependencies.

"resolution": {
    "modules": [
        {
            "organization": "org.scala-lang",
            "name": "scala3-library_3",
            "version": "3.5.2",
            "artifacts": [
                {
                    "name": "scala3-library_3",
                    "path": "/Users/kmarek/Library/Caches/Coursier/arc/https/github.com/scala/scala3/releases/download/3.5.2/scala3-3.5.2-aarch64-apple-darwin.tar.gz/scala3-3.5.2-aarch64-apple-darwin/maven2/org/scala-lang/scala3-library_3/3.5.2/scala3-library_3-3.5.2.jar"
                }
            ]
        },
        {
            "organization": "org.scala-lang",
            "name": "scala-library",
            "version": "2.13.14",
            "artifacts": [
                {
                    "name": "scala-library",
                    "path": "/Users/kmarek/Library/Caches/Coursier/arc/https/github.com/scala/scala3/releases/download/3.5.2/scala3-3.5.2-aarch64-apple-darwin.tar.gz/scala3-3.5.2-aarch64-apple-darwin/maven2/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar"
                }
            ]
        },
        {
            "organization": "com.lihaoyi",
            "name": "os-lib_3",
            "version": "0.11.3",
            "artifacts": [
                {
                    "name": "os-lib_3",
                    "path": "/Users/kmarek/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.3/os-lib_3-0.11.3.jar"
                },
                {
                    "name": "os-lib_3",
                    "classifier": "sources",
                    "path": "/Users/kmarek/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.3/os-lib_3-0.11.3-sources.jar"
                }
            ]
        },
        {
            "organization": "com.lihaoyi",
            "name": "geny_3",
            "version": "1.1.1",
            "artifacts": [
                {
                    "name": "geny_3",
                    "path": "/Users/kmarek/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/lihaoyi/geny_3/1.1.1/geny_3-1.1.1.jar"
                },
                {
                    "name": "geny_3",
                    "classifier": "sources",
                    "path": "/Users/kmarek/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/lihaoyi/geny_3/1.1.1/geny_3-1.1.1-sources.jar"
                }
            ]
        }
    ]
}

kasiaMarek avatar Feb 26 '25 13:02 kasiaMarek

@kasiaMarek that sounds like a bug in the scala wrapper then... Suspecting the source JARs aren't copied to the local repository during installation.

@hamzaremmal sounds like something we need to fix in the compiler repo.

Meanwhile, I suppose we should still warn the IDE when dependencySources come back empty.

Gedochao avatar Feb 27 '25 09:02 Gedochao

Meanwhile, I suppose we should still warn the IDE when dependencySources come back empty.

If you add any dependency they won't be empty even when sources for scala lib are missing, so I'm not sure how useful such a warning would actually be.

kasiaMarek avatar Feb 27 '25 12:02 kasiaMarek