Search code examples
scalasbtnexusgnupg

SBT Project Publish to Maven Central


I'm in the process of publishing my project in GitHub as a jar file to the Maven central nexus repo and I followed all the steps as mentioned in this documentation page from SBT!

https://www.scala-sbt.org/release/docs/Using-Sonatype.html

But now when I ran

sbt publishSigned

command against my project, I get the following error:

[info] Done packaging.
[error] gpg: keyblock resource '/Users/joesan/.sbt/gpg/secring.asc': No such file or directory
[error] gpg: no default secret key: No secret key
[error] gpg: signing failed: No secret key
[error] java.lang.RuntimeException: Failure running gpg --detach-sign.  Exit code: 2
[error]     at scala.sys.package$.error(package.scala:26)
[error]     at com.typesafe.sbt.pgp.CommandLineGpgSigner.sign(PgpSigner.scala:27)
[error]     at com.typesafe.sbt.pgp.PgpSettings$.$anonfun$signingSettings$2(PgpSettings.scala:157)
[error]     at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:240)
[error]     at scala.collection.immutable.Map$Map4.foreach(Map.scala:233)
[error]     at scala.collection.TraversableLike.flatMap(TraversableLike.scala:240)
[error]     at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:237)
[error]     at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104)
[error]     at com.typesafe.sbt.pgp.PgpSettings$.$anonfun$signingSettings$1(PgpSettings.scala:154)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]     at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]     at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.Execute.work(Execute.scala:278)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error]     at java.lang.Thread.run(Thread.java:748)
[error] (signedArtifacts) Failure running gpg --detach-sign.  Exit code: 2

Looks like it is expecting some secrte file and I do not have it on the path. How to get around with this issue? Any ideas?


Solution

  • Find out where the missing file (secring.asc) is on your computer, you should have it if you followed the instructions. Then set the location in your ~/.sbt/gpg.sbt file:

    pgpSecretRing := file("/tmp/secring.asc")