apheleia icon indicating copy to clipboard operation
apheleia copied to clipboard

Invalid argument

Open arijit-gogoi opened this issue 2 years ago • 5 comments

Apheleia gives exits with exit code 2 on Windows 11 with doom emacs:

Thu Dec 28 23:23:22 2023 :: c:/Users/hp/workspace/waiig/monkey-lang/token/
$ "diff" "--rcs" "--strip-trailing-cr" "--" "c:/Users/hp/workspace/waiig/monkey-lang/token/token.go" "-"

diff.exe: -: Invalid argument

Command succeeded with exit code 2.

arijit-gogoi avatar Dec 28 '23 17:12 arijit-gogoi

Sounds like a Windows problem. If you can suggest an alternative command line syntax for diff that'll work in this environment, I could implement it.

raxod502 avatar Dec 30 '23 21:12 raxod502

Hi @raxod502 !

This issue is very similar to what happens to me. You will see in OpenBSD the "diff" command that comes with it does not have the "--rcs" "--strip-trailing-cr" options and therefore fails with the same error code.

One way I see to solve this issue is to create a defcustom in which we can define the correct diff binary command (in my case gdiff, from GNU Coreutils, in the case of Windows to the correct diff binary).

In this link there is an idea of how this change would be implemented.

yukiteruamano avatar Feb 23 '24 03:02 yukiteruamano

Right, that makes sense. I'll have the default value be gdiff if available, diff otherwise. And the user can customize. On the first invocation, it will check to verify that the necessary options are supported, and report a better error if they aren't.

raxod502 avatar Feb 26 '24 03:02 raxod502

I get this error on Windows even when using GNU diff (installed via the scoop diffutils package):

$ diff.exe --version
diff (GNU diffutils) 3.6

I get no such error when invoking the identical command with call-process-region:

(call-process-region (point-min)
                     (point-max)
                     "diff"
                     nil
                     (get-buffer-create "test")
                     t
                     "--rcs"
                     "--strip-trailing-cr"
                     "--"
                     "c:/Users/josh/.emacs.d/init.el"
                     "-")

The above command returns a successful exit status and I can see the diff result in the test buffer.

So it's not clear to me yet why it fails for Apheleia.

jkxyz avatar Mar 30 '25 10:03 jkxyz

I submitted a fix for my version of this problem here: https://github.com/radian-software/apheleia/pull/356

jkxyz avatar Mar 30 '25 11:03 jkxyz