lucidsoftware / neo-sbt-scalafmt

Scalafmt SBT plugin
Apache License 2.0
149 stars 25 forks source link

"Runtime references to undefined settings" error when use sbt.ProjectRef #63

Open xuwei-k opened 6 years ago

xuwei-k commented 6 years ago

a/build.sbt

val b = project

build.sbt

val b = ProjectRef(file("a"), "b")

val c = project.dependsOn(b)

project/build.properties

sbt.version=0.13.16

project/plugin.sbt

addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.14")

error log

Runtime references to undefined settings: 
  {file:/home/travis/build/xuwei-k/neo-scalafmt-ProjectRef-error/a/}a/sbt:scalafmtOnCompile from */*:onLoad ((com.lucidchart.sbt.scalafmt.ScalafmtSbtPlugin) ScalafmtSbtPlugin.scala:16)
  {file:/home/travis/build/xuwei-k/neo-scalafmt-ProjectRef-error/a/}b/sbt:scalafmtOnCompile from */*:onLoad ((com.lucidchart.sbt.scalafmt.ScalafmtSbtPlugin) ScalafmtSbtPlugin.scala:16)

    at sbt.Init$class.Uninitialized(Settings.scala:270)
    at sbt.Def$.Uninitialized(Def.scala:10)
    at sbt.Init$class.make(Settings.scala:148)
    at sbt.Def$.make(Def.scala:10)
    at sbt.Load$$anonfun$8.apply(Load.scala:161)
    at sbt.Load$$anonfun$8.apply(Load.scala:156)
    at sbt.Load$.timed(Load.scala:1025)
    at sbt.Load$.apply(Load.scala:156)
    at sbt.Load$.defaultLoad(Load.scala:39)
    at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:503)
    at sbt.BuiltinCommands$.doLoadProject(Main.scala:503)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:495)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:495)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
    at sbt.Command$.process(Command.scala:93)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
    at sbt.State$$anon$1.runCmd$1(State.scala:183)
    at sbt.State$$anon$1.process(State.scala:187)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.MainLoop$.next(MainLoop.scala:96)
    at sbt.MainLoop$.run(MainLoop.scala:89)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
    at sbt.Using.apply(Using.scala:24)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
    at sbt.MainLoop$.runLogged(MainLoop.scala:22)
    at sbt.StandardMain$.runManaged(Main.scala:61)
    at sbt.xMain.run(Main.scala:35)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
    at xsbt.boot.Launch$.run(Launch.scala:109)
    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
    at xsbt.boot.Launch$.launch(Launch.scala:117)
    at xsbt.boot.Launch$.apply(Launch.scala:18)
    at xsbt.boot.Boot$.runImpl(Boot.scala:41)
    at xsbt.boot.Boot$.main(Boot.scala:17)
    at xsbt.boot.Boot.main(Boot.scala)
[error] Runtime references to undefined settings: 
[error] 
[error]   {file:/home/travis/build/xuwei-k/neo-scalafmt-ProjectRef-error/a/}a/sbt:scalafmtOnCompile from */*:onLoad ((com.lucidchart.sbt.scalafmt.ScalafmtSbtPlugin) ScalafmtSbtPlugin.scala:16)
[error] 
[error]   {file:/home/travis/build/xuwei-k/neo-scalafmt-ProjectRef-error/a/}b/sbt:scalafmtOnCompile from */*:onLoad ((com.lucidchart.sbt.scalafmt.ScalafmtSbtPlugin) ScalafmtSbtPlugin.scala:16)
[error]  
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 
1015bit commented 6 years ago

Hi. Are there any updates or workarounds for this issue?

pheymann commented 6 years ago

I am also running into this issue, but I am not able to grasp why it is failing when looking into the piece of code throwing this exception: https://github.com/lucidsoftware/neo-sbt-scalafmt/blob/1.10/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtSbtPlugin.scala#L16

Btw, my error looks a be different (v1.10 and sbt 1.0.5):

ProjectRef(uri("file:/Users/paul.heymann/<path to other subproject b>"), "b") / Sbt / scalafmtOnCompile from Global / onLoad ((com.lucidchart.sbt.scalafmt.ScalafmtSbtPlugin.globalSettings) ScalafmtSbtPlugin.scala:16)

My only guess it that Global hasn't evaluated b when resolving the ProjectRef and therefore cannot find the setting. But I would assume that it should be available since sbt brings the subproject sbt configuration into the scope of the parent project.

jvujcic commented 6 years ago

Hi, I'm also having this issue. Any updates?