Nbdev_diff_nbs does not work on windows 10

nbdev_diff_nbs gives me:

Traceback (most recent call last):
File "C:\Users\eta1si\.conda\envs\nbdev\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\eta1si\.conda\envs\nbdev\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\eta1si\.conda\envs\nbdev\Scripts\nbdev_diff_nbs.exe\__main__.py", line 7, in <module>
File "C:\Users\eta1si\.conda\envs\nbdev\lib\site-packages\fastcore\script.py", line 112, in _f
tfunc(**merge(args, args_from_prog(func, xtra)))
File "C:\Users\eta1si\.conda\envs\nbdev\lib\site-packages\nbdev\sync.py", line 155, in nbdev_diff_nbs
res = subprocess.run(['diff', '-ru', d1, d2], stdout=subprocess.PIPE)
File "C:\Users\eta1si\.conda\envs\nbdev\lib\subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\eta1si\.conda\envs\nbdev\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\eta1si\.conda\envs\nbdev\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified


I get the same error on the GitHub (Enterprise) Windows Runner in the company I work in. On the Linux runner it all works fine so it does appear that nbdev_diff_nbs just doesn’t work on Windows? Does anyone have a workaround for this?

BTW, I did find this post that might be relevant for solving the issue:

It looks like the definition of nbdev_diff_nbs does indeed not have the shell=True like the post says it should. Here’s the statement from nbdev/sync.py:
res = subprocess.run(['diff', '-ru', d1, d2], stdout=subprocess.PIPE)

Perhaps it should be res = subprocess.run(['diff', '-ru', d1, d2], stdout=subprocess.PIPE, shell=True) ?
@jeremy, @hamelsmu : Could this be a solution or has it been tried out already?

So I did an editable install of nbdev (that allowed me to edit the nbdev source code) and made the change:
res = subprocess.run(['diff', '-ru', d1, d2], stdout=subprocess.PIPE)res = subprocess.run(['diff', '-ru', d1, d2], stdout=subprocess.PIPE, shell=True).

On running nbdev_diff_nbsI got a different error:

'diff' is not recognized as an internal or external command,
operable program or batch file.


So I think I “hit the right spot” and now the error message is easier to interpret: I am on Windows (PowerShell) and it doesn’t understand the diff command.

I am going to put this on the back burner for now (and probably just shift to an Ubuntu runner) since I urgently need to develop my library before I can look at nbdev. Furthermore it looks like no one is really interested in this issue and Windows is just not a priority for nbdev.

For the sake of posterity, I would like to add that the following changes were needed in the settings.ini:

if [ -n "$(git status -uno -s)" ]; then echo "git status is not clean"; false; fi  if ( ($(git status -uno -s) | Measure-Object -line).Lines -eq 0) { echo "git status is clean"} else {echo "git status not clean!"; exit 10}


and

if [ -n "$(git status -uno -s)" ]; then echo -e "!!! Detected unstripped out notebooks\n!!!Remember to run nbdev_install_git_hooks"; false; fi  if ( ($(git status -uno -s) | Measure-Object -line).Lines -eq 0) { echo "Notebooks have been stripped out"} else {echo -e "!!! Detected unstripped out notebooks\n!!!Remember to run nbdev_install_git_hooks"; exit 20}


Clearly the “problems” occur when nbdev uses bash commands. Powershell doesn’t understand them.