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

unusedCompileDependenciesFilter usage #33

Open
anilkumarmyla opened this issue Apr 2, 2019 · 8 comments
Open

unusedCompileDependenciesFilter usage #33

anilkumarmyla opened this issue Apr 2, 2019 · 8 comments

Comments

@anilkumarmyla
Copy link
Contributor

anilkumarmyla commented Apr 2, 2019

I seemingly used unusedCompileDependenciesFilter as specified in README.md, but got errors during sbt run

project/build.properties

sbt.version=1.2.8

project/plugins.sbt

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.9")

build.sbt

unusedCompileDependenciesFilter -= moduleFilter("org.scalaz", "scalaz")

sbt update

error: No implicit for Remove.Value[explicitdeps.ModuleFilter, sbt.librarymanagement.ModuleFilter] found,
  so sbt.librarymanagement.ModuleFilter cannot be removed from explicitdeps.ModuleFilter
unusedCompileDependenciesFilter -= moduleFilter("org.scalaz", "scalaz")
                                ^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
@anilkumarmyla
Copy link
Contributor Author

Apparently this is caused by including the sbt-updates plugin
If I have addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0") in project/plugins.sbt , I get the above error message

@cb372
Copy link
Owner

cb372 commented Apr 3, 2019

I'm glad you found the cause just as I was about to start looking at this 😄

It's quite surprising though. Both plugins define their own type alias for sbt.librarymanagement.ModuleFilter (explicitdeps.ModuleFilter and com.timushev.sbt.updates.Compat.ModuleFilter respectively) but I wouldn't expect that to be a problem.

I'll do some digging and see if I can at least find a workaround.

@anilkumarmyla
Copy link
Contributor Author

thanks @cb372, this error baffles me since explicitdeps.ModuleFilter is a type alias for sbt.librarymanagement.ModuleFilter . I've tried some workarounds but none seemed to work

@cb372
Copy link
Owner

cb372 commented Apr 3, 2019

@anilkumarmyla I've found a workaround:

unusedCompileDependenciesFilter := moduleFilter() - moduleFilter("org.scalaz", "scalaz")

@anilkumarmyla
Copy link
Contributor Author

@cb372 It works! Have you gotten to the root cause of the behavior?

@anilkumarmyla
Copy link
Contributor Author

Just remembered that the documentation should also mention how to filter multiple modules rather than a single one so as to make the syntax clearer 😄

@cb372
Copy link
Owner

cb372 commented Apr 3, 2019

I've found the cause, and I'm an idiot. It's an ambiguous implicit.

sbt doesn't provide an instance of Remove.Value for ModuleFilter (maybe it should), so sbt-updates provides one here.

When I found that code in sbt-updates previously, I liked the idea and shamelessly stole it. So there's an identical instance in sbt-explicit-dependencies here, which causes an ambiguous implicit when you use both plugins. I completely forgot that I'd done that!

@anilkumarmyla
Copy link
Contributor Author

Interesting, I'd expect the scala compiler to throw an error/warning about the ambiguous implicit.

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