sbt-pgp icon indicating copy to clipboard operation
sbt-pgp copied to clipboard

Changing gpgCommand has no effect

Open Katrix opened this issue 6 years ago • 8 comments

Trying to make sbt-pgp use gpg2 by changing the gpgCommand key, but it doesn't seem to have any effect.

Using useGpg := true

sbt:scammanderRoot> set com.typesafe.sbt.pgp.PgpKeys.gpgCommand := "gpg2"
[info] Defining gpgCommand
[info] The new value will be used by no settings or tasks.
[info] Reapplying settings...
[info] Set current project to scammanderRoot (in build file:/mnt/d/DevProjects/Scammander/)
sbt:scammanderRoot> show pgpSigner
[info] spongeSponge7-0-0 / pgpSigner
[info]  GPG-Command(gpg)
[info] bukkit / pgpSigner
[info]  GPG-Command(gpg)
[info] spongeSponge5-1-0 / pgpSigner
[info]  GPG-Command(gpg)
[info] common / pgpSigner
[info]  GPG-Command(gpg)
[info] spongeSponge6-0-0 / pgpSigner
[info]  GPG-Command(gpg)
[info] pgpSigner
[info]  GPG-Command(gpg)
[success] Total time: 0 s, completed Jun 14, 2018 1:22:24 PM

Katrix avatar Jun 14 '18 13:06 Katrix

The same for me.... gpg in version 1.4.x is used by my update tool (slackpkg on slackware) and I can not override it. Instead of I have gpg2 installed. I need to point to gpg2 only for publishSigned

Work-around:

  • create symbolic link
ln -s /usr/bin/gpg2 $HOME/bin/gpg
  • run sbt as:
PATH=$HOME/bin:$PATH sbt

ajozwik avatar Jul 25 '19 07:07 ajozwik

Probably needs to be scoped globally.

set Global / gpgCommand := "gpg2"

eed3si9n avatar Sep 15 '19 21:09 eed3si9n

I am still getting this issue. Opened a stackoverflow question in case its me doing something wrong:

https://stackoverflow.com/questions/60029812/how-do-you-use-sbt-pgp-with-a-different-command-to-call-gpg-i-have-tried-gpgcom

@eed3si9n any thoughts?

softinio avatar Feb 03 '20 15:02 softinio

Let me reopen this issue.

eed3si9n avatar Feb 03 '20 16:02 eed3si9n

@eed3si9n thx ... is the fix for this simply adding to here:

https://github.com/sbt/sbt-pgp/blob/master/sbt-pgp/src/main/scala/com/jsuereth/sbtpgp/SbtPgp.scala#L30

def gpgCommand = PgpKeys.gpgCommand in Global

softinio avatar Feb 04 '20 05:02 softinio

I poked at this a bit in the scala-xml repo (as an arbitrary example of a repo that uses this plugin)

sbt:scala-xml> set com.typesafe.sbt.pgp.PgpKeys.gpgCommand := "gpg2"
[info] Defining gpgCommand
[info] The new value will be used by no settings or tasks.
[info] Reapplying settings...
[info] Set current project to scala-xml (in build file:/Users/tisue/modules/scala-xml/)
sbt:scala-xml> show gpgCommand
[info] xmlJS / gpgCommand
[info] 	gpg
[info] xml / gpgCommand
[info] 	gpg
[info] gpgCommand
[info] 	gpg2

note that the global setting changed but the value in each subproject didn't

but then:

sbt:scala-xml> set ThisBuild / com.typesafe.sbt.pgp.PgpKeys.gpgCommand := "gpg2"
[info] Defining ThisBuild / gpgCommand
[info] The new value will be used by no settings or tasks.
[info] Reapplying settings...
[info] Set current project to scala-xml (in build file:/Users/tisue/modules/scala-xml/)
sbt:scala-xml> show gpgCommand
[info] xmlJS / gpgCommand
[info] 	gpg2
[info] xml / gpgCommand
[info] 	gpg2
[info] gpgCommand
[info] 	gpg2

this time they all changed.

so maybe you want ThisBuild rather than Global?

SethTisue avatar Feb 04 '20 21:02 SethTisue

@SethTisue thanks for taking the time to help with this. Will give your suggestion a try.

softinio avatar Feb 06 '20 07:02 softinio

For changing command on Travis CI (Ubuntu) we use the next settings:

val gpgSettings = Seq(
  useGpgAgent := true,
  useGpgPinentry := true,
  usePgpKeyHex("XXXXXXX")
) ++ sys.env.get("TRAVIS").map( _ => gpgCommand in Global := "gpg2" )

ihostage avatar Mar 14 '20 01:03 ihostage