sbt-pgp will not sign by the key and fail due to GPG error.
When Global / pgpPassphrase := None
```scala
[error] gpg: using "89E12D0E3E013585D82565D91EE07D3261CE4CA6" as default secret key for signing
[error] gpg: signing failed: No passphrase given
[error] gpg: signing failed: No passphrase given
[error] java.lang.RuntimeException: Failure running 'gpg --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2
[error] at scala.sys.package$.error(package.scala:30)
[error] at com.jsuereth.sbtpgp.CommandLineGpgSigner.sign(PgpSigner.scala:48)
[error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$2(PgpSettings.scala:151)
[error] at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245)
[error] at scala.collection.immutable.Map$Map4.foreach(Map.scala:236)
[error] at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245)
[error] at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242)
[error] at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108)
[error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$1(PgpSettings.scala:146)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] at sbt.Execute.work(Execute.scala:290)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[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:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (signedArtifacts) Failure running 'gpg --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2
```
When Global / pgpPassphrase := Some(Array())
```scala
[error] gpg: using "89E12D0E3E013585D82565D91EE07D3261CE4CA6" as default secret key for signing
[error] gpg: signing failed: No passphrase given
[error] gpg: signing failed: No passphrase given
[error] java.lang.RuntimeException: Failure running 'gpg --batch --passphrase --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2
[error] at scala.sys.package$.error(package.scala:30)
[error] at com.jsuereth.sbtpgp.CommandLineGpgSigner.sign(PgpSigner.scala:48)
[error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$2(PgpSettings.scala:151)
[error] at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245)
[error] at scala.collection.immutable.Map$Map4.foreach(Map.scala:236)
[error] at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245)
[error] at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242)
[error] at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108)
[error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$1(PgpSettings.scala:146)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] at sbt.Execute.work(Execute.scala:290)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[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:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (signedArtifacts) Failure running 'gpg --batch --passphrase --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2
```
In these two cases: pgpPassphrase := Some(Array()) or None, there is a bit differences for gpg commands
If None, --batch and --passphrase is gone away
but if Some(Array()) then those options exist
The GPG wizard to enter the passphrase was shown in the both cases
expectation
Get the same result on useGpg := false
notes
Use Global / useGpg := false, the key work well
It would be caused by GPG's problem? 🤔
I tried to find the way how to sign a key without passphrase using --yes, --pinentry-mode loopback and --passphrase-fd 0 but still fail
Likewise I cannot add a passphrase to the key without passphrase generated by step (1)
Is there any reason why gpg cannot add passphrase even though it can generate keys without passphrase? I don't see it
steps
Create a GPG key without passphrase
We can show the key which was created by the above 👆 command:
Write
build.sbt
:or
Run
sbt release
Fail to sign
Information
sbt-pgp version: 2.0.1 sbt version: 1.3.12 gnupg version: 2.2.20
Initial
gpg
keys state:And run those command for
gpg
outputproblem
sbt-pgp
will not sign by the key and fail due to GPG error.When
```scala [error] gpg: using "89E12D0E3E013585D82565D91EE07D3261CE4CA6" as default secret key for signing [error] gpg: signing failed: No passphrase given [error] gpg: signing failed: No passphrase given [error] java.lang.RuntimeException: Failure running 'gpg --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 [error] at scala.sys.package$.error(package.scala:30) [error] at com.jsuereth.sbtpgp.CommandLineGpgSigner.sign(PgpSigner.scala:48) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$2(PgpSettings.scala:151) [error] at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245) [error] at scala.collection.immutable.Map$Map4.foreach(Map.scala:236) [error] at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245) [error] at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242) [error] at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$1(PgpSettings.scala:146) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:67) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19) [error] at sbt.Execute.work(Execute.scala:290) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281) [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:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] (signedArtifacts) Failure running 'gpg --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 ```Global / pgpPassphrase := None
When
```scala [error] gpg: using "89E12D0E3E013585D82565D91EE07D3261CE4CA6" as default secret key for signing [error] gpg: signing failed: No passphrase given [error] gpg: signing failed: No passphrase given [error] java.lang.RuntimeException: Failure running 'gpg --batch --passphrase --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 [error] at scala.sys.package$.error(package.scala:30) [error] at com.jsuereth.sbtpgp.CommandLineGpgSigner.sign(PgpSigner.scala:48) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$2(PgpSettings.scala:151) [error] at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245) [error] at scala.collection.immutable.Map$Map4.foreach(Map.scala:236) [error] at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245) [error] at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242) [error] at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$1(PgpSettings.scala:146) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:67) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19) [error] at sbt.Execute.work(Execute.scala:290) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281) [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:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] (signedArtifacts) Failure running 'gpg --batch --passphrase --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 ```Global / pgpPassphrase := Some(Array())
pgpPassphrase := Some(Array())
orNone
, there is a bit differences forgpg
commandsNone
,--batch
and--passphrase
is gone awaySome(Array())
then those options existexpectation
useGpg := false
notes
Global / useGpg := false
, the key work well--yes
,--pinentry-mode loopback
and--passphrase-fd 0
but still failgpg
cannot add passphrase even though it can generate keys without passphrase? I don't see it