node-gpg icon indicating copy to clipboard operation
node-gpg copied to clipboard

Error : spawn gpg ENOENT

Open taeverapon32 opened this issue 8 years ago • 8 comments

I try to run examples\encrypt.js and found the error results here

{ Error: spawn gpg ENOENT at exports._errnoException (util.js:1018:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) at onErrorNT (internal/child_process.js:367:16) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) at Module.runMain (module.js:606:11) at run (bootstrap_node.js:389:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:504:3 code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn gpg', path: 'gpg', spawnargs: [ '--batch', '--encrypt' ] }

taeverapon32 avatar Aug 29 '17 09:08 taeverapon32

any solution for the above issue?

satheeshtcs avatar Feb 07 '18 06:02 satheeshtcs

Have you installed gpg cli tool? What is the output of $ gpg --version ?

freewil avatar Feb 07 '18 06:02 freewil

I didn't installed gpg cli tool. I am installed using npm install gpg . Here is my code,

var gpg = require('gpg'),
...
gpg.encryptToFile({source:fileToWrite, dest: './export/test.dat' }, function(err, data){
                console.log(err);
 });

After running this file, I am getting the above error. But empty file is generated inside the export folder. is there anything need to add.

satheeshtcs avatar Feb 07 '18 07:02 satheeshtcs

I didn't installed gpg cli tool

You need to install this in order to use the npm package gpg. This package is a simple wrapper around the cli tool.

freewil avatar Feb 07 '18 08:02 freewil

@freewil I am using windows 10 machine. Can you explain which one can i download and install. Also please explain after installation which steps i can follow for using gpg encrypt/decrypt? UPDATE: I have installed the GnuPG in my windows machine. After the installation i set environment variable inside path as C:\Program Files (x86)\GNU\GnuPG . After that i tried gpg --version in command prompt. But i am getting the error like gpg is not recognized as an internal or external command, operable program or batch file. . can you explain which i am missing?

satheeshtcs avatar Feb 08 '18 07:02 satheeshtcs

@freewil , After setting C:\Program Files (x86)\GNU\GnuPG\pub in the environment variables i am able to see the gpg --version

gpg (GnuPG) 2.0.29 (Gpg4win 2.3.0)
libgcrypt 1.6.4
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: C:/Users/user/AppData/Roaming/gnupg
Supported algorithms:
Pubkey: RSA, RSA, RSA, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

I hope it was installed in my system. Then i tried in the code. Now the error is gone. but the file encrypted as 0KB. There is no data inside the file. The code for encryption is below,

gpg.encryptToFile({source:fileToWrite, dest: './export/test.txt' }, function(err, data){
                    console.log(err);
                    });

Suggest me is anything i am missing?

satheeshtcs avatar Feb 09 '18 09:02 satheeshtcs

@satheeshtcs, I am also facing the same error. Will you be able to find any solution for this?

rjain3 avatar Feb 09 '21 06:02 rjain3

I am facing this issue in the codecov-action v4, per https://github.com/codecov/codecov-action/issues/1279#issuecomment-2046096493. Same issue in GitHub hosted runners (macOS-12 and macOS-13), macOS-14 does not have the problem.

gpg --version

gpg (GnuPG) 2.4.5
libgcrypt 1.10.3
Copyright (C) 2024 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/runner/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD[16](https://github.com/LizardByte/Sunshine/actions/runs/8651443319/job/23722157891#step:5:17)0, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

https://github.com/codecov/codecov-action/pull/1371

ReenigneArcher avatar Apr 11 '24 18:04 ReenigneArcher