diff error message suggestion
(1) By n.carter (swapsycarter) on 2025-03-17 11:55:12 [link] [source]
For Fossil 2.25 2024-11-06, I'd like to suggest that the diff command's error message provide more information about its origin:
When running diff, I received the error "The System Cannot Find the File Specified", and I wasn't certain whether this message was issued by Windows (and 'passed along' by Fossil), or by Fossil itself. Having earlier run the mv command on the file I was diffing, I thought I had made some mistake in the mv process, or there was corruption in the Fossil repository, and spent a considerable amount of time trying to diagnose the fault. But it turns out that I was looking in the wrong place.
Whilst writing to the forum to ask for help, inadvertent Rubber Ducking brought the real source of the problem to mind: my diff-command setting was wrong; some weeks earlier, I had moved the batch script mentioned in this setting.
If Fossil's error message contains a hint as to the source of the original message, it could help narrow down the troubleshooting process.
(2) By Stephan Beal (stephan) on 2025-03-17 12:23:53 in reply to 1 [link] [source]
If Fossil's error message contains a hint as to the source of the original message...
Fossil doesn't actually know the origin of that message (which is coming from Windows, according to internet search engines) beyond that the message was emitted as part of the current fossil command invocation (in your case "diff"). The "hint" you're asking for is that any errors fossil emits are going to be related to its current command.
However...
As of a moment ago, if the OS reports "failed" for an external diff, fossil will emit a warning that the "external diff failed" and shows the external diff command it tried to invoke:
$ f set diff-command /foo/bar/baz $ f diff Index: src/diffcmd.c ================================================================== sh: 1: /foo/bar/baz: not found External diff command failed: /foo/bar/baz $ f unset diff-command $ f diff -c 2 Index: src/diffcmd.c ================================================================== --- src/diffcmd.c +++ src/diffcmd.c @@ -670,5 +670,8 @@ /* Run the external diff command */ - fossil_system(blob_str(&cmd)); + if( fossil_system(blob_str(&cmd)) ){ + fossil_warning("External diff command failed: %b\n", + &cmd); + } /* Delete the temporary file and clean up memory used */
(Sidebar: as seen above, on Linux the OS apparently provides enough context to stderr to make the source of the error clear.)
(3) By n.carter (swapsycarter) on 2025-03-18 09:54:21 in reply to 2 [link] [source]
Thanks for the helpful reply.
Some clarification in case it's useful to anyone encountering a similar problem...
First, the message was "the path specified", not "the file specified", as I wrote. And I'm running Windows 11.
As you suggest, I wasn't sure whether the error had occurred during the system call, or within Fossil's own operations. It seemed possible that Fossil contained an error message identical to the one I got, which I knew was a classic Windows message.
Inspired by your message, I did some testing (with the latest snapshot 2025-03-13) and obtained two different (Windows) error messages, apparently issued during the system call. "cannot find the path" appears when any of the directories mentioned along the path did not exist, thus referring to a non-existent directory. If, on the other hand, the path is correct, but the actual file is not present in that directory, one gets the other Windows classic: "... not recognized as an internal or external command, operable program or batch file".
Seems I should have interpreted the original error message more literally (and checked the source code)!
Although my problem is now resolved, it might be useful to mention that I couldn't produce the "External diff command failed" message shown in the source code snippet. On Windows, fossil_system() returns the value returned by Windows' built-in _wsystem(), so I tried a diff-command setting that sets Windows' errorlevel to 1 ("vim.exe -nonsense"). But that did not invoke Fossil's error message; perhaps Windows' command interpreter consumed Vim's return value, or it was contained in errno instead.
(4.1) By Stephan Beal (stephan) on 2025-03-18 10:12:24 edited from 4.0 in reply to 3 [source]
On Windows, fossil_system() returns the value returned by Windows' built-in _wsystem(), so I tried a diff-command setting that sets Windows' errorlevel to 1 ("vim.exe -nonsense"). But that did not invoke Fossil's error message; perhaps Windows' command interpreter consumed Vim's return value, or it was contained in errno instead.
That's interesting. i've just run the following test on Win11:
$ fossil set diff-command no-such-command $ fossil pull $ fossil diff --from trunk ... Index: www/changes.wiki ================================================================== 'no-such-command' is not recognized as an internal or external command, operable program or batch file. External diff command failed: no-such-command C:/Users/Stephan/AppData/Local/Temp/changes~orig.wiki C:/f/f/www/changes.wiki
which shows that the fossil_system() call is getting a non-zero from _wsystem()
. That implies that your result code is getting lost somewhere along the way.