4

I get the following error when running Git commit:

c:/Program/ Files/ /(x86/)/Notepad++/notepad++.exe: -c: line 0: syntax
 error near unexpected token `('
c:/Program/ Files/ /(x86/)/Notepad++/notepad++.exe: -c: line 0: `c:/Pr
ogram/ Files/ /(x86/)/Notepad++/notepad++.exe \$@\'
error: There was a problem with the editor 'c:/Program/ Files/ /(x86/)
/Notepad++/notepad++.exe'.
Please supply the message using either -m or -F option.

What does it mean? How can I fix it?

2 Answers 2

5

I was just running into this, and found your question trying to figure it out. I too assumed it needed escape characters for the spaces and parentheses IN .gitconfig, but apparently not. This statement worked for me:

editor = C:/Program Files (x86)/Notepad++/notepad++.exe

Which was created in my .gitconfig file by the below command:

git config --global core.editor /c/Program\ Files\ \(x86\)/Notepad\+\+/notepad\+\+.exe

I had to remove the invalid line, before setting it with the above command would work.

Unfortunately, git commit still didn't work. Adding both Quotation marks and single quotes around it finally worked, launching the COMMIT_EDITMSG in my running Notepad++ window:

editor = "'C:/Program Files (x86)/Notepad++/notepad++.exe'"

Platform is Windows 8.1 Pro x64, the MINGW64/Bash shell, installed from the https://git-scm.com Windows client.

Sign up to request clarification or add additional context in comments.

2 Comments

The single-quotes-within-double-quotes is a very good tip for this use case.
I didn't think it would be necessary. The double quotes seem to contain any parameters passed to the editor, and the single quotes pass the editor path with spaces. Without any parameters, the double and single quotes were still necessary for it to work. However, git wouldn't properly recognize when I had saved and closed the memo file, and would think it was blank, voiding the commit. I found adding -multiInst -notabbar -nosession between the end single quote and double quote fixed this, launching a new window that was recognized when closed.
1

Looks like the prepare-commit-msg hook or the editor option in the gitconfig has a typo. You call c:/Program/ Files/ /(x86/)/Notepad++/notepad++.exe but you should have called c:/Program\ Files\ \(x86\)/Notepad++/notepad++.exe (use backslashes to escape space and bracket, not slash)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.