'openvpn client electron: Error opening configuration

I had struggling with the same error of running a child process with admin privileges for the past two days. this is my code :

var sudo = require("sudo-prompt");
.
.
 initializeit(binarypath,options){
        return new Promise((resolve, reject)=>{
            var arg = [
                '--proto-force',
                'udp',
                '--dev',
                'tun0',
                '--auth-nocache',
                '--remote',
                options.host,
                options.port,
                '--config',
                "$(PWD)"+options.config,
                '--daemon', "vpnworld"
              ];
              var option = {
                name: 'VPN WORLD',
                icns: this.icns, // (optional)
              };
              try {
                sudo.exec(binarypath+" "+arg.join(" "),option,
                function(error, stdout, stderr) {
                  if (error) reject(error);
                  resolve('stdout: ' + stdout);
                }
              )   
              } catch (error) {
                  reject(error)
              }
        })
    }

and this is the out put from stout:

[electron] connect err: Error: Command failed: ./Assets/bin/sbin/openvpn --proto-force udp --dev tun0 --auth-nocache --remote vpn.example.com 1194 --config $(PWD)/Assets/client.ovpn --daemon vpnworld
[electron] Options error: In [CMD-LINE]:1: Error opening configuration file: /Users/novyjpolzovatel/Desktop/vpndesktop/Assets/client.ovpn
[electron] Use --help for more information.
[electron] 
[electron]     at /Users/novyjpolzovatel/Desktop/vpndesktop/node_modules/sudo-prompt/index.js:390:27
[electron]     at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3) {
[electron]   code: 1
[electron] }

this config path it's just fine, I tried the same command from terminal, and it works, in fact I changed the path into absolute and then relative (with different possible initialization point).

Any help would be appreciated to launch OpenVPN client instance from electron.

sudo popup:

enter image description here

break point in sudo-prompt:

function MacResult(instance, end) {
  var cwd = Node.path.join(instance.path, 'Contents', 'MacOS');
  Node.fs.readFile(Node.path.join(cwd, 'code'), 'utf-8',
    function(error, code) {
      if (error) {
        if (error.code === 'ENOENT') return end(new Error(PERMISSION_DENIED));
        end(error);
      } else {
        Node.fs.readFile(Node.path.join(cwd, 'stdout'), 'utf-8',
          function(error, stdout) {
            if (error) return end(error);
            Node.fs.readFile(Node.path.join(cwd, 'stderr'), 'utf-8',
              function(error, stderr) {
                if (error) return end(error);
                code = parseInt(code.trim(), 10); // Includes trailing newline.
                if (code === 0) {
                  end(undefined, stdout, stderr);
                } else {
                  error = new Error(  // <<<<< here 
                    'Command failed: ' + instance.command + '\n' + stderr + stdout
                  );
                  error.code = code;
                  end(error, stdout, stderr);
                }
              }
            );
          }
        );
      }
    }
  );
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source