So today I did my work, did:
- git add .
- git commit -m "message"
- git push origin main
And that's when I got the following error:
error: cannot spawn sh: No such file or directory
error: cannot spawn c:\Users\MyName\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass.sh: No such file or directory
fatal: could not read Username for 'https://github.com': No such file or directory
Tried editing .gitconfig with the comment I saw on another post but nothing.
Edit for more info: The repository is private, didn't have any issues previously. I cloned the repository with HTTPS, should I use SSH?
CodePudding user response:
When Git needs to prompt for a password, it looks in the environment variables GIT_ASKPASS
or SSH_ASKPASS
or the configuration option core.askPass
(although not in that order). In order to invoke such a program, Git needs to spawn a shell, and on your system, it can't do so. From the output, it looks like maybe VS Code has set up some type of helper and it isn't working.
The easiest way to fix this is to make sure those environment variables and configuration value are unset. If that's the case, Git will prompt you on the command line.
Otherwise, you need to figure out why VS Code has set up the command in a broken way on your system and fix that such that it doesn't do so. How exactly to do that is left as an exercise for the reader (since I'm not a VS Code user).
CodePudding user response:
Could be that your SSH key has expired. Try generating it again and update it. https://docs.github.com/en/authentication/connecting-to-github-with-ssh