Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error downloading SBT dependency sources when SBT version is not in the artifact name #6922

Open
alejandrohdezma opened this issue Nov 9, 2024 · 3 comments

Comments

@alejandrohdezma
Copy link

Describe the bug

All of a sudden, when trying to use Metals at $WORK, when the server is loading it fails to download certain dependencies for our main SBT plugin:

Could not fetch dependency sources for Dependency(my.company:my-sbt-plugin_2.12_1.0;sbtVersion=1.0;scalaVersion=2.12, 0.16.4, Configuration(), Set(), Publication(, Type(), Extension(), Classifier()), false, true), error: coursier.error.ResolutionError$Several:
Error downloading com.thoughtworks.sbt-api-mappings:sbt-api-mappings_2.12_1.0:3.0.2
  not found: /Users/alex/.ivy2/local/com.thoughtworks.sbt-api-mappings/sbt-api-mappings_2.12_1.0/3.0.2/ivys/ivy.xml
  not found: https://repo1.maven.org/maven2/com/thoughtworks/sbt-api-mappings/sbt-api-mappings_2.12_1.0/3.0.2/sbt-api-mappings_2.12_1.0-3.0.2.pom
  download error: Caught java.net.ConnectException (Operation timed out) while downloading https://oss.sonatype.org/content/repositories/releases/com/thoughtworks/sbt-api-mappings/sbt-api-mappings_2.12_1.0/3.0.2/sbt-api-mappings_2.12_1.0-3.0.2.pom
  not found: https://jitpack.io/com/thoughtworks/sbt-api-mappings/sbt-api-mappings_2.12_1.0/3.0.2/sbt-api-mappings_2.12_1.0-3.0.2.pom
  not found: https://my.company/artifactory/maven/com/thoughtworks/sbt-api-mappings/sbt-api-mappings_2.12_1.0/3.0.2/sbt-api-mappings_2.12_1.0-3.0.2.pom (Artifactory Realm)
  not found: https://repo1.maven.org/maven2/com/thoughtworks/sbt-api-mappings/sbt-api-mappings_2.12_1.0/3.0.2/sbt-api-mappings_2.12_1.0-3.0.2.pom
  not found: https://oss.sonatype.org/content/repositories/public/com/thoughtworks/sbt-api-mappings/sbt-api-mappings_2.12_1.0/3.0.2/sbt-api-mappings_2.12_1.0-3.0.2.pom
Error downloading io.github.davidmweber:flyway-sbt_2.12_1.0:7.4.0
  not found: /Users/alex/.ivy2/local/io.github.davidmweber/flyway-sbt_2.12_1.0/7.4.0/ivys/ivy.xml
  not found: https://repo1.maven.org/maven2/io/github/davidmweber/flyway-sbt_2.12_1.0/7.4.0/flyway-sbt_2.12_1.0-7.4.0.pom
  not found: https://oss.sonatype.org/content/repositories/releases/io/github/davidmweber/flyway-sbt_2.12_1.0/7.4.0/flyway-sbt_2.12_1.0-7.4.0.pom
  not found: https://jitpack.io/io/github/davidmweber/flyway-sbt_2.12_1.0/7.4.0/flyway-sbt_2.12_1.0-7.4.0.pom
  not found: https://my.company/artifactory/maven/io/github/davidmweber/flyway-sbt_2.12_1.0/7.4.0/flyway-sbt_2.12_1.0-7.4.0.pom (Artifactory Realm)
  not found: https://repo1.maven.org/maven2/io/github/davidmweber/flyway-sbt_2.12_1.0/7.4.0/flyway-sbt_2.12_1.0-7.4.0.pom
  not found: https://oss.sonatype.org/content/repositories/public/io/github/davidmweber/flyway-sbt_2.12_1.0/7.4.0/flyway-sbt_2.12_1.0-7.4.0.pom
Error downloading org.portable-scala:sbt-platform-deps_2.12_1.0:1.0.1
  not found: /Users/alex/.ivy2/local/org.portable-scala/sbt-platform-deps_2.12_1.0/1.0.1/ivys/ivy.xml
  not found: https://repo1.maven.org/maven2/org/portable-scala/sbt-platform-deps_2.12_1.0/1.0.1/sbt-platform-deps_2.12_1.0-1.0.1.pom
  not found: https://oss.sonatype.org/content/repositories/releases/org/portable-scala/sbt-platform-deps_2.12_1.0/1.0.1/sbt-platform-deps_2.12_1.0-1.0.1.pom
  not found: https://jitpack.io/org/portable-scala/sbt-platform-deps_2.12_1.0/1.0.1/sbt-platform-deps_2.12_1.0-1.0.1.pom
  not found: https://my.company/artifactory/maven/org/portable-scala/sbt-platform-deps_2.12_1.0/1.0.1/sbt-platform-deps_2.12_1.0-1.0.1.pom (Artifactory Realm)
  not found: https://repo1.maven.org/maven2/org/portable-scala/sbt-platform-deps_2.12_1.0/1.0.1/sbt-platform-deps_2.12_1.0-1.0.1.pom
  not found: https://oss.sonatype.org/content/repositories/public/org/portable-scala/sbt-platform-deps_2.12_1.0/1.0.1/sbt-platform-deps_2.12_1.0-1.0.1.pom

All these dependencies are SBT plugins themselves but noticed non of them are published following the general SBT plugin schema that Metals is expecting my-artifact_2.12_1.0-x.x.x vs my_artifact_2.12-x.x.x.

After this error started appearing I've been unable to use Metals since the server is no longer loading the available projects in my SBT build.

The issue only happens when using SBT server, it runs fine when using Bloop.

Expected behavior

Metals is able to load this dependencies correctly by using my_artifact_2.12-x.x.x as a fallback for SBT plugins.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.4.0

Extra context or search terms

Tested in Metals 1.3.4, 1.3.5 and 1.4.0, which have been running for a while, but issue started happening yesterday.

See for example the difference in publishing in sbt-platform-deps:

https://repo1.maven.org/maven2/org/portable-scala/sbt-platform-deps_2.12_1.0/1.0.2/

@tgodzik
Copy link
Contributor

tgodzik commented Nov 10, 2024

Did you change SBT version recently? I think this error comes from SBT itself if I am not mistaken.

Alternatively, it could be our fallback, but I am pretty sure it's behind a try

@alejandrohdezma
Copy link
Author

I didn't think about that initially because running any command on the SBT shell itself worked fine but yesterday I did manage to fix it by upgrading the internal SBT plugin that we use at $WORK. The plugin upgrade didn't include any build changes but was just a dependency update with the following:

  • SBT 1.10.2 to 1.10.3 (in the plugin project, the project where this failed is still on 1.10.1.
  • sbt-scalafix from 0.12.1 to 0.13.0
  • sbt-dynver from 5.0.1 to 5.1.0

Could any of this affect how Metals retrieve those dependencies? It's odd because even if I remove every Coursier cache and restore the repository, SBT is still able to retrieve the plugins, but Metals isn't.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 11, 2024

Sbt doesn't download sources by default, only when requested by metals, which is why the shell would work. If metals is unable to request the sources it should just get an empty list and we could deal with that. But it seems the server fails at that point and it shouldn't

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants