git-js icon indicating copy to clipboard operation
git-js copied to clipboard

Error: spawn git ENOENT in electron and windows

Open mhcgolds opened this issue 6 years ago • 1 comments

I know it has some content about this issue over there but they couldn't help in my case. I'm trying to create a simple hello world app but I can't open the repo.

enter image description here

And this is my code:

const git = require('simple-git');
const path = require('path').join('G:', 'marcio.chaves', 'Documents', 'Projects', 'SimpleFarm');
const fs = require('fs');
const stat = fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK);

console.log(path, stat);

git(path).raw(
[
  'branch',
  '--merged',
  'master'
], (err, result) => {
  // err is null unless this command failed
  // result is the raw output of this command
  console.log(result);
});

path is ok, it is a valid git repository of a project I work daily basis about 4 years. stats is undefined what means(according to fs docs) that those permissions tested(R_OK and W_OK) are ok as well.

Some details: Win 10, node 10.15.0, electron 4.1.3, simple-git 1.110.0, callstack.

Every resource I've found says that the error is about path issues, like not found path or permission related problem. Is there any other cause for that and i'm missing it ?

mhcgolds avatar Apr 02 '19 20:04 mhcgolds

Not sure if you figured this out but the problem isn't the path to the file, it can't find git on the machine you're running it on.

keithslater avatar Jul 18 '19 14:07 keithslater