Why does sbt 1.0.2 hang after compilation? - scala

I have installed sbt 1.0.2 and tried building the "hello project", but it hangs after done compilation.
I waited for 2 hours and it does not complete. what am I missing here?
HOSTPC:IdeaProjects XYZ2017$ sbt new sbt/scala-seed.g8
[info] Loading settings from plugins.sbt ...
[info] Loading global plugins from /Users/XYZ2017/.sbt/1.0/plugins
[info] Set current project to ideaprojects (in build file:/Users/XYZ2017/IdeaProjects/)
A minimal Scala project.
name [Scala Seed Project]: hello
Template applied in ./hello
HOSTPC:IdeaProjects XYZ2017$ ls
hello
HOSTPC:IdeaProjects XYZ2017$ cd hello/
HOSTPC:hello XYZ2017$ sbt
[info] Loading settings from plugins.sbt ...
[info] Loading global plugins from /Users/XYZ2017/.sbt/1.0/plugins
[info] Loading project definition from /Users/XYZ2017/IdeaProjects/hello/project
[info] Updating {file:/Users/XYZ2017/IdeaProjects/hello/project/}hello-build...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/XYZ2017/IdeaProjects/hello/project/target/scala-2.12/sbt-1.0/classes ...
[info] Done compiling.

Related

Why can't SBT run a specific main?

My Scala 3 code starts with
#main def primer(): Unit = {
. . .
}
and when I use
% sbt run
It runs fine...
% sbt run
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.13)
[info] loading global plugins from /Users/eric.kolotyluk/.sbt/1.0/plugins
[info] loading project definition from /Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/project
[info] loading settings for project root from build.sbt ...
[info] set current project to fp-laboratory (in build file:/Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/)
[info] running com.forgerock.fp.laboratory.primer
Primer running... with 11.0.13+10-LTS-370
Note: SBT believes it is running com.forgerock.fp.laboratory.primer
But, if I try
% sbt "runMain com.forgerock.fp.laboratory.primer"
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.13)
[info] loading global plugins from /Users/eric.kolotyluk/.sbt/1.0/plugins
[info] loading project definition from /Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/project
[info] loading settings for project root from build.sbt ...
[info] set current project to fp-laboratory (in build file:/Users/eric.kolotyluk/git/autonomous-iam/poc/fp-laboratory/)
[info] running com.forgerock.fp.laboratory.primer
Primer running... with 11.0.13+10-LTS-370
Exception in thread "sbt-bg-threads-1" java.lang.NoClassDefFoundError: org/apache/spark/sql/SparkSession
at com.forgerock.fp.laboratory.Primer$package$.primer(Primer.scala:30)
So, clearly, run and runMain do not do the same thing.
Is there a way to make runMain do the right thing?
Is this caused by some weirdness with the Scala 3 #main annotation?

How to change sbt version for project

I have build.properties file in the project with the following line:
sbt.version=1.2.8
build.properties file is in the same folder as build.sbt file.
But when I enter the command "sbt about", it reports 1.0.3. Following is the actual output of the command:
/Users/kale> sbt about
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /Users/kale/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from
/Users/kale/workspace/gr8Project/myapp/project
[info] Loading settings from build.sbt ...
[info] Set current project to myapp (in build
file:/Users/kale/workspace/gr8Project/myapp/)
[info] This is sbt 1.0.3
[info] The current project is
{file:/Users/kale/workspace/gr8Project/myapp/}myapp 0.1-SNAPSHOT
[info] The current project is built against Scala 2.12.8
[info] Available Plugins: sbt.plugins.IvyPlugin,
sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin,
sbt.plugins.JUnitXmlReportPlugin,
sbt.plugins.Giter8TemplatePlugin, sbtassembly.AssemblyPlugin,
com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin,
com.lucidchart.sbt.scalafmt.ScalafmtPlugin,
com.lucidchart.sbt.scalafmt.ScalafmtSbtPlugin,
scoverage.ScoverageSbtPlugin,
net.virtualvoid.sbt.graph.DependencyGraphPlugin,
sbtdocker.DockerPlugin, Build, Docker
[info] sbt, sbt plugins, and build definitions are using Scala
2.12.4
How can I change sbt version to 1.2.8?
your project structure should be <root>/project/build.properties, and then you should change the sbt version property (see https://github.com/pedrorijo91/play-slick3-steps/blob/master/project/build.properties as an example)
Use sbt about to know the version in use.

How can I debug an sbt-coursier hang-on-startup issue?

How can I debug an sbt-coursier hang-on-startup issue? (Note, I'm also using sbt-assembly.)
I would really like to use sbt-coursier, but it's just not working for me. Platform is Windows 10, I hope that's not why. What's odd is that even though sbt-coursier supposedly no longer uses the dreadful .sbt.ivy.lock file, I still see it appear when I am using sbt-coursier. It's almost as though sbt-couriser is waiting on it ...forever..., but that doesn't make sense to me, because I thought in recent versions sbt-coursier completely moved away from using .sbt.ivy.lock.
When I try to use the sbt-cousier plugin, my sbt session hangs during startup.
// This is file: ~/.sbt/1.0/plugins/build.sbt
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M10")
// console output
[info] Loading settings for project global-plugins from build.sbt,idea.sbt,plugins.sbt ...
[info] Loading settings for project global-plugins from idea6673.sbt ...
[info] Loading global plugins from C:\Users\me\.sbt\1.0\plugins
[info] Updating ProjectRef(uri("file:/C:/Users/me/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project myapp-build from assembly.sbt ...
If I go back to not using sbt-coursier, everything is fine.
// This is file: ~/.sbt/1.0/plugins/build.sbt
// addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M10")
// console output
[info] Loading settings for project global-plugins from build.sbt,idea.sbt,plugins.sbt ...
[info] Loading settings for project global-plugins from idea62602.sbt ...
[info] Loading global plugins from C:\Users\me\.sbt\1.0\plugins
[info] Updating ProjectRef(uri("file:/C:/Users/me/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading settings for project myapp-build from assembly.sbt ...
[info] Loading project definition from C:\Users\me\Documents\C\IdeaProjects\MyApp\project
[info] Updating ProjectRef(uri("file:/C:/Users/me/Documents/C/IdeaProjects/MyApp/project/"), "myapp-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project myapp from build.sbt ...
[info] Set current project to myapp (in build file:/C:/Users/me/Documents/C/IdeaProjects/MyApp/)
[IJ]sbt:myapp>

addSbtPlugin(...) cause eviction warning but 'evicted' command shows nothing

With sbt 1.2.7 and sbt-pgp plugin, sbt shows eviction warning.
$ rm -rf target project/target && sbt ";clean;compile"
[info] Loading global plugins from /home/kbigwheel/.sbt/1.0/plugins
[info] Loading project definition from /home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/project/project
[info] Loading settings for project plugins-build from test.sbt ...
[info] Loading project definition from /home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/project
[info] Updating ProjectRef(uri("file:/home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/project/"), "plugins-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project plugins from build.sbt ...
[info] Set current project to plugins (in build file:/home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/)
[success] Total time: 0 s, completed 2019/01/05 13:27:05
[info] Updating ...
[info] Done updating.
[success] Total time: 0 s, completed 2019/01/05 13:27:05
However, evicted command shows nothing.
$ sbt evicted
[info] Loading global plugins from /home/kbigwheel/.sbt/1.0/plugins
[info] Updating ProjectRef(uri("file:/home/kbigwheel/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading project definition from /home/kbigwheel/proj-name/project/project
[info] Updating ProjectRef(uri("file:/home/kbigwheel/proj-name/project/project/"), "proj-name-build-build")...
[info] Done updating.
[info] Loading settings for project proj-name-build from test.sbt ...
[info] Loading project definition from /home/kbigwheel/proj-name/project
[info] Updating ProjectRef(uri("file:/home/kbigwheel/proj-name/project/"), "proj-name-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Set current project to proj-name (in build file:/home/kbigwheel/proj-name/)
[info] Updating ...
[info] Done updating.
[success] Total time: 0 s, completed 2019/01/05 13:52:46
Additional Info
With sbt 1.1.6, no warnings
With sbt 1.2.0, warning occured
With sbt-sonatype, no warnings
With sbt-native-packager, warning occured
Therefore, this warning must happens with specific plugin and sbt 1.2.0 or higher.
source to reproduce: https://github.com/bigwheel/sbt-unknown-evicted-warning
Why the warning shows ? and how to resolve this message ?
Remember that SBT is recuersive - that means, SBT uses SBT to build the SBT used to build your project.
The eviction warning you are seeing is not for your main project, but for the meta-project!
You can check that by running the evicted command in the meta project using the reload plugins command.
(I will be using sbt as shell instead of as a batch command executor, which is better and faster for development).
$ sbt
[info] Updated file /home/balmungsan/sbt-unknown-evicted-warning/project/build.properties: set sbt.version to 1.2.7
[info] Loading settings for project global-plugins from plugins.sbt ...
[info] Loading global plugins from /home/balmungsan/.sbt/1.0/plugins
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project/project
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/project/"), "sbt-unknown-evicted-warning-build-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project sbt-unknown-evicted-warning-build from plugins.sbt ...
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/"), "sbt-unknown-evicted-warning-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Set current project to sbt-unknown-evicted-warning (in build file:/home/balmungsan/sbt-unknown-evicted-warning/)
[info] sbt server started at local:///home/balmungsan/.sbt/1.0/server/91ac4486f32705bdcc38/sock
sbt:sbt-unknown-evicted-warning> evicted
[info] Updating ...
[info] Done updating.
[success] Total time: 3 s, completed Jan 5, 2019 9:49:12 AM
sbt:sbt-unknown-evicted-warning> reload plugins
[info] Loading settings for project global-plugins from plugins.sbt ...
[info] Loading global plugins from /home/balmungsan/.sbt/1.0/plugins
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project/project
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/project/"), "project-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project project from plugins.sbt ...
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project
sbt:project> evicted
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/"), "project")...
[info] Done updating.
[info] Here are other dependency conflicts that were resolved:
[info] * org.scala-lang.modules:scala-parser-combinators_2.12:1.0.5 is selected over 1.0.4
[info] +- com.jsuereth:pgp-library_2.12:1.1.1 (depends on 1.0.5)
[info] +- com.typesafe:ssl-config-core_2.12:0.2.2 (depends on 1.0.4)
[success] Total time: 11 s, completed Jan 5, 2019 9:50:25 AM
(PS: To return to the main project execute the reload return command).

SBT does not want to enter my project (using project command)

My build is simple:
lazy val stampleWebProject = play.Project("stample-web", appVersion, appDependencies,path = file("stample-web"))
.dependsOn(stampleCoreProject,stampleSearchProject)
.aggregate(stampleCoreProject,stampleSearchProject)
lazy val stampleCoreProject = Project(id = "stample-core",base = file("stample-core"))
lazy val stampleSearchProject = Project(id = "stample-search",base = file("stample-search"))
All these projects have a build.sbt file with dependencies, without any scala build (which would be ignored as far as I know)
When I start SBT (12.4), I get the following:
[info] Set current project to stample-core (in build file:/home/sebastien/Bureau/Stample/)
> projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] * stample-core
[info] stample-search
[info] stample-web
> project stample-search
[info] Set current project to stample-search (in build file:/home/sebastien/Bureau/Stample/)
> projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] stample-core
[info] * stample-search
[info] stample-web
> project stample-core
[info] Set current project to stample-core (in build file:/home/sebastien/Bureau/Stample/)
> projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] * stample-core
[info] stample-search
[info] stample-web
> project stample-web
[info] Set current project to stample-search (in build file:/home/sebastien/Bureau/Stample/)
[stample-search] $ projects
[info] In file:/home/sebastien/Bureau/Stample/
[info] stample-core
[info] stample-search
[info] * stample-web
[stample-search] $ compile
[info] Updating {file:/home/sebastien/Bureau/Stample/}stample-core...
[info] Resolving org.slf4j#slf4j-api;1.6.6 ...
[info] Done updating.
[info] Updating {file:/home/sebastien/Bureau/Stample/}stample-web...
[error] a module is not authorized to depend on itself: stample-search#stample-search_2.10;1.0
[error] (stample-web/*:update) java.lang.IllegalArgumentException: a module is not authorized to depend on itself: stample-search#stample-search_2.10;1.0
[error] Total time: 1 s, completed 26 août 2013 21:57:45
I do not understand some stuff here:
How is choosen the project in which we are by default. I've seem documentation was added in SBT 13.0 but did not see it in the 12.4 multibuild documentation.
How comes I type project stample-web and it tells me I'm in stample-search
Why is there a special display in my sbt console for the project I'm in (stample-web or stample-search, I don't really know...) (this appears here: [stample-search] $ compile, is this relative to play projects?
Why it can't compile stample-search, since it doesn't depend on itself in my build (I suspect it tries to compile the web project but there's a naming problem or something?
Is this an SBT bug. If so, is it possible to use the new 13.0 version with Play framework?
Eugene Yokota is right: I have a conflict in the stample-web folder, which was set the stample-web name in the scala build, but it has a wrong build.sbt in the folder which has name := stample-search