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

Adding resolvers to build.sbt doesn't work #5172

Closed
lukoyanov opened this issue Oct 9, 2019 · 9 comments
Closed

Adding resolvers to build.sbt doesn't work #5172

lukoyanov opened this issue Oct 9, 2019 · 9 comments
Labels

Comments

@lukoyanov
Copy link

lukoyanov commented Oct 9, 2019

steps

sbt version: 1.3.2, 1.3.0, 1.2.8

problem

when I add a resolver to my build.sbt using

resolvers in ThisBuild += "r1" at "https://jcenter.bintray.com/"

OR

resolvers += "r2" at "https://jcenter.bintray.com/"

resolver is not added. I've checked it via "show fullResolvers"

expectation

Resolver is added and used for artifacts resolution.

notes

  1. I've deleted my ~/.sbt, ~/.ivy, ~/.m2 to be sure no tricky configuration options is getting in the way.
  2. When I create ~/.sbt/repositories file and add url there everything work fine
  3. I've attached super minimal sbt project to reproduce the issue, to do it please run:
$ sbt
sbt> show resolvers
sbt> show fullResolvers

and compare results (I expect that "fullResolvers" list contains all items from "resolvers" list)

My output is:

sbt:minimal-sbt> show resolvers
[info] * r1: https://jcenter.bintray.com/
[info] * r2: https://jcenter.bintray.com/
sbt:minimal-sbt> show fullResolvers
[info] * Raw(ProjectResolver(inter-project, mapped: ))
[info] * FileRepository(local, Patterns(ivyPatterns=Vector(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)([branch]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=Vector(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)([branch]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), FileConfiguration(true, None))
[info] * FileRepository(local-preloaded-ivy, Patterns(ivyPatterns=Vector(/Users/lukoyanov/.sbt/preloaded/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=Vector(/Users/lukoyanov/.sbt/preloaded/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), FileConfiguration(true, None))
[info] * local-preloaded: file:////Users/lukoyanov/.sbt/preloaded/
[info] * public: https://repo1.maven.org/maven2/
[info] * sbt-maven-releases: https://repo.scala-sbt.org/scalasbt/maven-releases/
[info] * sbt-maven-snapshots: https://repo.scala-sbt.org/scalasbt/maven-snapshots/
[info] * URLRepository(typesafe-ivy-releases, Patterns(ivyPatterns=Vector(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=Vector(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), false)
[info] * URLRepository(sbt-ivy-snapshots, Patterns(ivyPatterns=Vector(https://repo.scala-sbt.org/scalasbt/ivy-snapshots/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=Vector(https://repo.scala-sbt.org/scalasbt/ivy-snapshots/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), false)
[success] Total time: 0 s, completed 09.10.2019 23:40:35

project to reproduce

sbt-sample.tar.gz

@lukoyanov lukoyanov added the Bug label Oct 9, 2019
@eed3si9n eed3si9n added the area/library_management library management label Oct 9, 2019
@eed3si9n
Copy link
Member

eed3si9n commented Oct 9, 2019

@lukoyanov Thanks for the report. I agree with your expectation.

There's a setting called useJCenter (default: false) so that's likely interfering with manual addition of JCenter resolver.

@lukoyanov
Copy link
Author

lukoyanov commented Oct 10, 2019

@eed3si9n thank you for quick reply.

I've just tried to add my corporate artifactory url and sbt behaviour stays the same (resolvers not being added).
I've changed resolvers configuration to this:

resolvers in ThisBuild += "r1" at "https://repo.infotech.team/artifactory/dev-maven/"
resolvers += "r2" at "https://repo.infotech.team/artifactory/dev-maven/"

And sbt output was:

sbt:minimal-sbt> show resolvers
[info] * r1: https://repo.infotech.team/artifactory/dev-maven/
[info] * r2: https://repo.infotech.team/artifactory/dev-maven/
sbt:minimal-sbt> show fullResolvers
[info] * Raw(ProjectResolver(inter-project, mapped: ))
[info] * FileRepository(local, Patterns(ivyPatterns=Vector(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)([branch]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=Vector(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)([branch]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), FileConfiguration(true, None))
[info] * cache:Maven2 Local: /Users/lukoyanov/.m2/repository
[info] * maven-central: https://repo1.maven.org/maven2/
[info] * jcenter: https://jcenter.bintray.com/
[info] * URLRepository(sbt-releases-repo, Patterns(ivyPatterns=Vector(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=Vector(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), false)
[info] * URLRepository(sbt-plugins-repo, Patterns(ivyPatterns=Vector(https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=Vector(https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), false)
[success] Total time: 0 s, completed 10.10.2019 10:26:14

It seems that it's not related to JCenter (and useJCenter configuration option), but an issue affects more generic case.

I think many projects rely on this way of resolvers configuration so a workaround would be very helpful.

@lebenitza
Copy link

@lukoyanov shouldn't rezolvers be added to plugins.sbt?

@lukoyanov
Copy link
Author

Well, as far as I remember it's correct to add resolvers to build.sbt.

I didn't find any restrictions in docs:
https://www.scala-sbt.org/1.x/docs/Resolvers.html

@lebenitza
Copy link

lebenitza commented Apr 2, 2020

Indeed but I added them to plugins.sbt and it worked. I ended up on this issue because adding them to build.sbt did not work for me either with sbt 1.3.4. Maybe it works for you too as a workaround until this is fixed or they fix the docs.

@lukoyanov
Copy link
Author

@MihaiAnei Thank you for sharing this piece of information. I've ended up adding required repositories into .sbt/repositories file (global configuration).

@ches
Copy link
Contributor

ches commented Apr 5, 2020

I can't reproduce this with the attached minimal sbt-sample file. sbt 1.2.8, 1.3.2; the original repeats of JCenter resolvers in the attached file, or two other different resolvers; useCoursier on and off in 1.3.2. All work as expected.

Do you possibly have -Dsbt.override.build.repos=true being set somewhere, like /usr/local/etc/sbtopts? (Installation-dependent, check sbt --help which should report where it is on your install). Or does your organization deploy custom sbt launchers that may set it?

@lukoyanov
Copy link
Author

lukoyanov commented Apr 17, 2020

Do you possibly have -Dsbt.override.build.repos=true being set somewhere ...

Indeed, I have this option set to true in /usr/local/etc/sbtopts.

Looks like this was the root cause of the issue. Thank you @ches!

@kyrsideris
Copy link

In my case, I had the following in my shell:

SBT_OPTS=-Dsbt.override.build.repos=true

Unset it and it worked! :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants