I am starting a new project in scala. I use emacs as editor.
So far it cannot be more simple. This is the build.sbt
name := "Sampler"
version := "1.0"
scalaVersion := "2.11.8"
I have run the ensimeConfig command in sbt (0.13 version)
When I start ensime on Emacs (M-ensime) I get the following error:
13:34:52.511 ERROR None Server - There was a problem parsing /home/jeronimo/prog/coursera/progfun2/circuits/.ensime
java.lang.NoSuchMethodError: shapeless.DataT$.genTraversableDataT(Lshapeless/Lazy;Lscala/collection/generic/CanBuildFrom;)Lshapeless/DataT;
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1.inst$macro$320$lzycompute(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1.inst$macro$320(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1$$anonfun$inst$macro$319$1.apply(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1$$anonfun$inst$macro$319$1.apply(EnsimeConfigProtocol.scala:61)
at shapeless.Lazy$$anon$1.value$lzycompute(lazy.scala:121)
at shapeless.Lazy$$anon$1.value(lazy.scala:121)
at shapeless.EverywhereAux$$anonfun$default$2.apply(sybclass.scala:184)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:40)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:38)
at shapeless.PolyDefns$Case.apply(poly.scala:37)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:144)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:142)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:144)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:142)
at shapeless.DataT1$$anon$9.gmapT(sybclass.scala:116)
at shapeless.EverywhereAux$$anonfun$default$2.apply(sybclass.scala:184)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:40)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:38)
at shapeless.PolyDefns$Case.apply(poly.scala:39)
at org.ensime.core.Canonised$.apply(Canon.scala:19)
at org.ensime.config.EnsimeConfigProtocol$.validated(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$$anonfun$3.apply(EnsimeConfigProtocol.scala:44)
at org.ensime.config.EnsimeConfigProtocol$$anonfun$3.apply(EnsimeConfigProtocol.scala:44)
at scala.collection.immutable.List.map(List.scala:273)
at org.ensime.config.EnsimeConfigProtocol$.validated(EnsimeConfigProtocol.scala:44)
at org.ensime.config.EnsimeConfigProtocol$.parse(EnsimeConfigProtocol.scala:32)
at org.ensime.server.Server$.main(Server.scala:120)
at org.ensime.server.Server.main(Server.scala)
Exception in thread "main" java.lang.NoSuchMethodError: shapeless.DataT$.genTraversableDataT(Lshapeless/Lazy;Lscala/collection/generic/CanBuildFrom;)Lshapeless/DataT;
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1.inst$macro$320$lzycompute(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1.inst$macro$320(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1$$anonfun$inst$macro$319$1.apply(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$anon$default$macro$337$1$$anonfun$inst$macro$319$1.apply(EnsimeConfigProtocol.scala:61)
at shapeless.Lazy$$anon$1.value$lzycompute(lazy.scala:121)
at shapeless.Lazy$$anon$1.value(lazy.scala:121)
at shapeless.EverywhereAux$$anonfun$default$2.apply(sybclass.scala:184)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:40)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:38)
at shapeless.PolyDefns$Case.apply(poly.scala:37)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:144)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:142)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:144)
at shapeless.DataT$$anon$12.gmapT(sybclass.scala:142)
at shapeless.DataT1$$anon$9.gmapT(sybclass.scala:116)
at shapeless.EverywhereAux$$anonfun$default$2.apply(sybclass.scala:184)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:40)
at shapeless.Cases$Case1$$anon$1$$anonfun$1.apply(cases.scala:38)
at shapeless.PolyDefns$Case.apply(poly.scala:39)
at org.ensime.core.Canonised$.apply(Canon.scala:19)
at org.ensime.config.EnsimeConfigProtocol$.validated(EnsimeConfigProtocol.scala:61)
at org.ensime.config.EnsimeConfigProtocol$$anonfun$3.apply(EnsimeConfigProtocol.scala:44)
at org.ensime.config.EnsimeConfigProtocol$$anonfun$3.apply(EnsimeConfigProtocol.scala:44)
at scala.collection.immutable.List.map(List.scala:273)
at org.ensime.config.EnsimeConfigProtocol$.validated(EnsimeConfigProtocol.scala:44)
at org.ensime.config.EnsimeConfigProtocol$.parse(EnsimeConfigProtocol.scala:32)
at org.ensime.server.Server$.main(Server.scala:120)
at org.ensime.server.Server.main(Server.scala)
Process *inferior-ensime-server-circuits* exited abnormally with code 1
After trying to delete the .ivy2 cache without success I fixed the issue re-installing the EMACS ensime plugin.
Related
This is the first time ever i am trying to publish an artifact, and it could not be harder.
I am using sbt 0.13.8 with plug-ins sbt-release 1.0.8, sbt-sonatype 2.0 sbt-pgp 1.1.1
relevant part of my build sbt looks like this:
pgpSecretRing := file("""C:\Users\kali\.sbt\gpg\secring.asc""")
pgpPublicRing := file("""C:\Users\kali\.sbt\gpg\pubring.asc""")
//pgpSecretRing := file("""C:\Users\kali\AppData\Local\lxss\home\kali\.gnupg\secring.gpg""")
//pgpPublicRing := file("""C:\Users\kali\AppData\Local\lxss\home\kali\.gnupg\pubring.gpg""")
usePgpKeyHex("c500a525a2efcb99")
name := "project-name"
organization := "com.mehmetyucel"
version := "0.0.2-SNAPSHOT"
scalaVersion := "2.12.2"
crossScalaVersions := Seq("2.11.11", "2.12.2")
lazy val projectName = project in file(".")
homepage := Some(url("https://some-github-url"))
scmInfo := Some(
ScmInfo(url(
"some-github-url"),
"some-github-url.git"))
developers := List(
Developer(
"mehmetyucel",
"Mehmet Yucel",
"mehmet#mehmetyucel.com",
url("some-github-url")))
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
publishMavenStyle := true
publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
)
releaseCrossBuild := true
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
)
The first 5 lines here I added out of desperation because when I do sbt release "I think" it signs my packages with a key that i am not aware of.
the error message i get is:
[info] Evaluate: signature-staging
[info] Failed: signature-staging, failureMessage:No public key: Key with id: (5b09423c9d5fbb5d) was not able to be located on http://keyserver.ubuntu.com:11371/. Upload your public key and try the operation again.
but my key is already uploaded. I can go and find my key on keyserver.ubuntu.com (http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC500A525A2EFCB99) unfortunately you will realize that the key id here is different. And I have no idea where this "5b09423c9d5fbb5d" is coming from.
I tried cloning the repository into 3 differnt systems (macos, ubuntu and win10) create a brand new key upload the key to ubuntu keyserver and try to release it again. The id in the error message is always same (5b09423c9d5fbb5d) I have no idea where this is coming from and how it is same despite using a totally different key/system
I tried changing usePgpKeyHex("c500a525a2efcb99") to usePgpKeyHex("c500a525a2efcb91") (basically something that does not exist) and I get
[error] Not a valid command: failure-- (similar: onFailure)
[error] Not a valid project ID: failure--
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: failure--
[error] failure--
[error] ^
on signing stage, which is awesome, which actually means sbt is using my key to sign so, still where does 5b09423c9d5fbb5d come from?
Solved:
Apparently this key id was coming from the very first "publishSigned" i did for this project, which failed for another reason. I kept running publishSigned sonatypeRelease back to back quite a few times and this caused a lot of "open" staging repositories in sonatype.
I went to https://oss.sonatype.org/ and dropped all open staging repositories using nexus UI and restarted the release process and everything works.
I have a subproject in my build.sbt with a rather long setting for initialCommands, comprising a list of imports and some definitions. I'd like to test this as part of regular CI, because otherwise I won't notice breaking changes after refactoring code. It is not clear to me how to do so.
Just running sbt console doesn't seem to cut it, because there is always a "successful" exit code even when code doesn't compile.
Moving the code out into an object defined in a special source file won't help because I need the list of imports to be present (and I don't want to cakeify my whole code base).
Moving the code out into a source file and then loading that with :load also always gives a successful exit code.
I found out about scala -e but that does strange things on my machine (see the error log below).
This is Scala 2.12.
$ scala -e '1'
cat: /release: No such file or directory
Exception in thread "main" java.net.UnknownHostException: <my-host-name-here>: <my-host-name-here>: Name or service not known
You could generate a file and run it like any other test file:
(sourceGenerators in Test) += Def.task {
val contents = """object TestRepl {
{{}}
}""".replace("{{}}", (initialCommands in console).value)
val file = (sourceManaged in Test).value / "repltest.scala"
IO.write(file, contents)
Seq(file)
}.taskValue
Here is how it was configured for Sbt 0.12.x:
parallelExecution in test := false
testGrouping in Test <<= definedTests in Test map { tests =>
tests.map { test =>
import Tests._
import scala.collection.JavaConversions._
new Group(
name = test.name,
tests = Seq(test),
runPolicy = SubProcess(javaOptions = Seq(
"-server", "-Xms4096m", "-Xms4096m", "-XX:NewSize=3584m",
"-Xss256k", "-XX:+UseG1GC", "-XX:+TieredCompilation",
"-XX:+UseNUMA", "-XX:+UseCondCardMark",
"-XX:-UseBiasedLocking", "-XX:+AlwaysPreTouch") ++
System.getProperties.toMap.map {
case (k, v) => "-D" + k + "=" + v
}))
}.sortWith(_.name < _.name)
}
During migration to Sbt 0.13.x I get the following error:
[error] Could not accept connection from test agent: class java.net.SocketException: socket closed
java.net.SocketException: socket closed
at java.net.DualStackPlainSocketImpl.accept0(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
at java.net.ServerSocket.implAccept(ServerSocket.java:530)
at java.net.ServerSocket.accept(ServerSocket.java:498)
at sbt.ForkTests$$anonfun$mainTestTask$1$Acceptor$2$.run(ForkTests.scala:48)
at java.lang.Thread.run(Thread.java:745)
Migration changes are just updates in sbt & plugin versions.
Are there any other approaches to forking and ordering of tests in Sbt 0.13.x to overcome that exception?
Works fine on Linux and Mac OS.
Got error on Windows because of limit of classpath length that prevents launching of test agent instance with following error in System.err:
Error: Could not find or load main class sbt.ForkMain
I also got this error when moving to Scala repo to sbt version sbt.version = 1.3.8 (previously 1.2.8 was ok). Strangely worked fine on my mac, but failed on teamcity linux build agents.
Fix for me was to set
fork := false,
in build.sbt.
Not sure why repo had it previously set to fork := true (guess it was cut/paste from somewhere else as no strong reason for this in this repo), but this change resolved the issue. Locally on my mac also runs a few seconds faster now.
See here for background
https://www.scala-sbt.org/1.0/docs/Forking.html
I m trying to create a standalone version of my Play! application , when I do play run it works fine , but after doing play dist
I get following error when I run the start command
I m using play2.1 and Scala 2.10.0
Oops, cannot start the server.
#6e25l921m: Cannot init the Global object
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:57)
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:51)
at play.utils.Threads$.withContextClassLoader(Threads.scala:18)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:50)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:383)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance(Application.scala:383)
at play.api.WithDefaultGlobal$class.global(Application.scala:66)
at play.api.DefaultApplication.global(Application.scala:383)
at play.api.WithDefaultConfiguration$class.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:80)
at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration$lzycompute(Application.scala:383)
at play.api.DefaultApplication.play$api$WithDefaultConfiguration$$fullConfiguration(Application.scala:383)
at play.api.WithDefaultConfiguration$class.configuration(Application.scala:82)
at play.api.DefaultApplication.configuration(Application.scala:383)
at play.api.Application$class.$init$(Application.scala:268)
at play.api.DefaultApplication.(Application.scala:383)
at play.core.StaticApplication.(ApplicationProvider.scala:52)
at play.core.server.NettyServer$.createServer(NettyServer.scala:228)
at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:259)
at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:258)
at scala.Option.map(Option.scala:145)
at play.core.server.NettyServer$.main(NettyServer.scala:258)
at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: java.lang.NoSuchMethodError: com.typesafe.config.ConfigFactory.load(Lcom/typesafe/config/ConfigParseOptions;)Lcom/typesafe/config/Config;
at play.api.Configuration$.dontAllowMissingConfig$lzycompute(Configuration.scala:25)
at play.api.Configuration$.dontAllowMissingConfig(Configuration.scala:25)
at play.api.Configuration$.load(Configuration.scala:59)
at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration$1.apply(Application.scala:74)
at play.api.WithDefaultConfiguration$$anonfun$initialConfiguration$1.apply(Application.scala:74)
at play.utils.Threads$.withContextClassLoader(Threads.scala:18)
at play.api.WithDefaultConfiguration$class.initialConfiguration(Application.scala:73)
at play.api.DefaultApplication.initialConfiguration$lzycompute(Application.scala:383)
at play.api.DefaultApplication.initialConfiguration(Application.scala:383)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalClass(Application.scala:24)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass$lzycompute(Application.scala:383)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalClass(Application.scala:383)
at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:30)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal$lzycompute(Application.scala:383)
at play.api.DefaultApplication.play$api$WithDefaultGlobal$$javaGlobal(Application.scala:383)
at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:52)
... 21 more
I ran into the same issue. The exact fix was to change a dependency from
"org.skife.com.typesafe.config" % "typesafe-config" % "0.3.0"
to
"com.typesafe" % "config" % "1.0.0"
I figured out that I was using "org.skife.com.typesafe.config" % "typesafe-config" % "0.3.0" in the build.sbt , and the play start was using com.typesafe.config-1.0.0, removing the dependency for skife config 0.3.0 solved the problem.
seems like these 2 dependencies conflict with each other.
When using sbt with forking (fork in run := true), every output from my application to stdout is prefixed by [info]; output to stderr is prefixed with [error].
This behavior is somewhat annoying when using a Java logging framework which outputs to stderr. The resulting debug messages typically look like this:
[error] [main] INFO MyClass ...
[error] [main] DEBUG MyClass ...
I would like to suppress these prefixes like when running the code without forking. What I tried:
setting sbt -Dsbt.log.noformat=true in the sbt launch script. But this only removes colored ANSI output; prefixes are still there just without color
setting logLevel in run := Level.Error in build.sbt. This does not seem to have any influence on logging with forking.
Is there any way to suppress the prefixes?
You need to set the output strategy of your project.
In my extended build I have the following settings:
settings = Project.defaultSettings ++ Seq(
fork := true, // Fork to separate process
connectInput in run := true, // Connects stdin to sbt during forked runs
outputStrategy := Some(StdoutOutput) // Get rid of output prefix
// ... other settings
)
Can do
sbt -error ...
and also
sbt -warn ...