These are chat archives for sbt/sbt

2nd
Mar 2017
Erem Boto
@eboto
Mar 02 02:12
Hi everyone...quick question about task dependency. I'm trying to override the classloader used in test (housed in the testLoader TaskKey) and I can't seem to successfully make it depend on other TaskKeys. Curious if I'm doing anything obviously wrong
name := "test-project"

testLoader := {
  // The next line produces this error:
  //   [error] Reference to undefined setting: 
  //   [error] 
  //   [error]   *:fullClasspath from *:testLoader (/Users/eboto/code/testloader/build.sbt:4)
  //   [error]      Did you mean compile:fullClasspath ?
  val a = fullClasspath.value


  getClass.getClassLoader
}
^-- that build.sbt is sufficient to produce the error
if you comment out the val a then sbt successfully starts
Erem Boto
@eboto
Mar 02 02:18
Not sure why it's apparently fine in Defaults.scala but not in my build
Erem Boto
@eboto
Mar 02 02:26
(sbt 0.13.11 btw)
Paul Phillips
@paulp
Mar 02 02:26
@eboto .sbt files aren't exactly scala, they're a sort of scala generating dsl. := is a macro and could be doing just about anything to rewrite that method body. So you can't infer behavior by looking at the sbt source.
Erem Boto
@eboto
Mar 02 02:31
Thanks @paulp. Hm would it be more informative to repro this in a Build.scala instead then?
Paul Phillips
@paulp
Mar 02 02:32
@eboto yep.
At least, less uninformative.
It'll still be a macro but at least you can remove the .sbt layer of opacity, which is significant.
Erem Boto
@eboto
Mar 02 02:37
ok done
import sbt.Keys._

object TestBuild {
  val someSettings = Seq(
    testLoader := {
      val a = fullClasspath.value

      getClass.getClassLoader
    }
  )
}
and meanwhile build.sbt still exists but its just
lazy val proj = (project in file(".")).settings(TestBuild.someSettings: _*)
I mean I'm still using the macro, but I'll admit that I don't know how to set a setting onto a project without := =/
(the error is still the same)
Erem Boto
@eboto
Mar 02 02:50
Ok I've ditched the .sbt altogether and this is still sufficient to cause the bug
import sbt._
import sbt.Keys._

object TestBuild extends Build {
  lazy val project = Project (
   "my-project",
   file ("."),
   settings = Seq(
      name := "my-project",
      testLoader := {
        val a = fullClasspath.value
        getClass.getClassLoader
      }
    )
  )
}
I mean it's not a bug...more likely that I'm not understanding something fundamental here
Erem Boto
@eboto
Mar 02 03:14
OK I think it was supposed to be (fullClasspath in Test) rather than (fullClasspath in test)
Dale Wijnand
@dwijnand
Mar 02 07:04
@eboto those settings are run through inConfig(Test)
which maps the LHS and the RHS to be scoped to in Test
you're not doing that in your version in build.sbt
so that's why you're behaviour is different
Good question. That's never explained anywhere. The only first time I knew it is when I finally grokked what inConfig did.
It eventually calls Project.transform which is defined as:
  def transform(g: Scope => Scope, ss: Seq[Def.Setting[_]]): Seq[Def.Setting[_]] = {
    val f = mapScope(g)
    ss.map(_ mapKey f mapReferenced f)
  }
mapReferenced means "map the keys referenced in the RHS"
andyr
@arobson73
Mar 02 08:55
are there any plugins for getting sbt metrics (to see why it takes so long to compile sometimes) ? stuff like took 10 seconds doing this, 30 seconds doing that ? Just looking at the scala-exercises (exercises-fpinscala). one line change taking between 30 to 60 seconds to compile.
andyr
@arobson73
Mar 02 09:36
just found out your not suppose to use sbt for scala-exercises.
Dale Wijnand
@dwijnand
Mar 02 09:39
There's no generic tool to describe where compile time is going. To my knowledge.
Paul Phillips
@paulp
Mar 02 09:43
Wherever it's going, it's not coming back
andyr
@arobson73
Mar 02 10:08
maybe not what the compiler is doing, but more what sbt is doing. maybe i need to enable some flags, but a tool that shows it (summarises) rather than a bit log to wade through.
Dale Wijnand
@dwijnand
Mar 02 10:11
andyr
@arobson73
Mar 02 10:13
thanks looks useful.
Rob Norris
@tpolecat
Mar 02 22:51
So, I have a program that uses ANSI cursor movement to write out ...... while it's working and then erase the line when it's done. When I run the program in sbt it sometimes doesn't work; I get a newline instead. But after a few runs it starts working.
I'm guessing it's something nutty that either sbt or JLine is doing with stdout. Has anyone seen anything remotely like this?
I hate to spend time chasing down something so dumb but that's how I roll. Unfortunately.
Hm actually it only misbehaves after I clear the screen with Cmd+K, then after about 20 lines of output it starts working.
Dale Wijnand
@dwijnand
Mar 02 22:58
Never seen anything like that. I've played around with ANSI things, but always using JLine.
Rob Norris
@tpolecat
Mar 02 22:59
Ghosts, probably. I'm going to pretend it's not happening and maybe it will go away.
Dale Wijnand
@dwijnand
Mar 02 23:00
Come back if/when you get more angry about it. I'd be happy to help where I can to figure it out.
Paul Phillips
@paulp
Mar 02 23:17
@tpolecat sbt strips ansi sequences from strings it gets its hands on. How are you writing output? Try System.out for instance to see if it's different if you bypass sbt.
Rob Norris
@tpolecat
Mar 02 23:18
@paulp Console.print which I assumed would be the same as System.out.print but I'll switch it up and see what happens.
Paul Phillips
@paulp
Mar 02 23:18
Actually I guess it replaces System.out.
Rob Norris
@tpolecat
Mar 02 23:18
urk
Paul Phillips
@paulp
Mar 02 23:18
No, Console.print is very likely not the same.
Rob Norris
@tpolecat
Mar 02 23:18
ok
no difference. it's weird, it starts working about halfway through the second run.
Then is fine again until I clear the screen.
sigh
Dale Wijnand
@dwijnand
Mar 02 23:23
sbt/sbt#789 would indicate no such ansi stripping. But then ¯\(ツ)/¯ can one trust a 2 comment issue from 2013
Btw @paulp was it intentional that Console has it's own versions of out/err/in, different to System.out/err/in?
And if so, what was the intention?
Paul Phillips
@paulp
Mar 02 23:26
It predates me.
Rob Norris
@tpolecat
Mar 02 23:26
Ok thanks for giving me a platform to discuss my haunting. I'm going to put a bucket over my head for now and forge ahead.
Dale Wijnand
@dwijnand
Mar 02 23:26
Ok, thanks Paul
Paul Phillips
@paulp
Mar 02 23:27
My statement that sbt strips them was based on seeing that the facilities are there to do it. It's possible they aren't utilized.