Skip to content

Commit 217e3a8

Browse files
authored
fix(publib-maven): fails with "Subprocess failed with exit code 1" (#1677)
In the old bash version, we had the following command: ```sh set -eu some_function() { export GPG_TTY=$(tty) } ``` If there is no tty, this fails with exit code 1 but that doesn't stop the script if the failing subshell is part of an `export` command. On GitHub Actions there is no tty which didn't stop the original script, but *does* stop the new script. Configure `nothrow: true` on the `tty` subshell to avoid stopping the command.
1 parent 782a90b commit 217e3a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/bin/publib-maven.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,9 @@ async function importGpgKey(key: PrivateKey) {
485485
// GnuPG will occasionally bail out with "gpg: <whatever> failed: Inappropriate ioctl for device", the following attempts to fix
486486
const gpgHome = autoCleanDir();
487487
try {
488-
const tty = (await $({ stdio: ['inherit', 'pipe', 'pipe'] })`tty`).stdout;
488+
// In CI environments there will be no tty, and we don't want this to stop the script.
489+
// The variable will be populated with a nonsensical string ("not a tty") but that doesn't seem to matter.
490+
const tty = (await $({ stdio: ['inherit', 'pipe', 'pipe'], nothrow: true })`tty`).stdout;
489491

490492
let privateKeyFile;
491493
const type = key.type;

0 commit comments

Comments
 (0)