portable-scala/sbt-crossproject

Ambigious implicit for `%%%`

cb372 opened this issue · 3 comments

cb372 commented

I encountered this when trying to add scala-native support to a project, following the instructions in this repo's README. Then I was able to reproduce it in one of the scripted-tests sbt projects under sbt-crossproject-test.

Steps to reproduce:

cd sbt-crossproject-test/src/sbt-test/new-api/cross-dependencies

mkdir -p project
echo "sbt.version=0.13.16" > project/build.properties
echo <<EOF > project/plugins.sbt
addSbtPlugin("org.scala-js"       % "sbt-scalajs"              % "0.6.19")
addSbtPlugin("org.portable-scala" % "sbt-crossproject"         % "0.3.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.3.0")
addSbtPlugin("org.scala-native"   % "sbt-scala-native"         % "0.3.3")
EOF

sbt

Error:

[info] Loading project definition from /Users/chris/code/sbt-crossproject/sbt-crossproject-test/src/sbt-test/new-api/cross-dependencies/project
/Users/chris/code/sbt-crossproject/sbt-crossproject-test/src/sbt-test/new-api/cross-dependencies/build.sbt:22: error: type mismatch;
 found   : $12b0424f132c9a6188b8.g.type (with underlying type String)
 required: ?{def %%%(x$1: ? >: String): ?}
Note that implicit conversions are not applicable because they are ambiguous:
 both method toPlatformDepsGroupID in object autoImport of type (groupID: String)org.portablescala.sbtplatformdeps.PlatformDepsGroupID
 and method toCrossGroupID in object AutoImport of type (groupID: String)sbtcrossproject.CrossGroupID
 are possible conversion functions from $12b0424f132c9a6188b8.g.type to ?{def %%%(x$1: ? >: String): ?}
  libraryDependencies += g %%% a % v
                         ^
/Users/chris/code/sbt-crossproject/sbt-crossproject-test/src/sbt-test/new-api/cross-dependencies/build.sbt:22: error: value %%% is not a member of String
  libraryDependencies += g %%% a % v

If I publishLocal the sbt plugins and then change the versions in plugins.sbt to use those:

addSbtPlugin("org.portable-scala" % "sbt-crossproject"         % "0.3.1-SNAPSHOT")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.3.1-SNAPSHOT")

then the problem goes away. But that doesn't make any sense to me, because the only commit since the 0.3.0 release was a change to the README!

Any ideas? Am I doing something stupid?

sjrd commented

Ah I think you need an exclude clause for sbt-scala-native:

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.3" exclude("org.scala-native", "sbt-crossproject"))

to ensure that the old dependency of sbt-scala-native on "org.scala-native" % "sbt-crossproject" % "0.2.2" is thrown away.

Normally ivy resolution would take care of that, but the change of organization between 0.2.x and 0.3.x prevents it from happening.

Once there is a new version of sbt-scala-native depending on 0.3.x, this won't be necessary anymore.

cb372 commented

That did the trick. Thank you!

You may want to add this to the readme, I had the same issue upgrading the monocle build.