How to get 'diff' on Windows TravisCI machines

My attempt was as follows:

choco install git -y, but it does not seem to be available:

The command "diff -u <(echo -n) <(gofmt -d ./)" exited with 2.
diff: /dev/fd/62: No such file or directory

In Travis CI (specifically when running on Windows) git is installed but doesn’t usually add the diff executable to the path because it would conflict with other versions of diff native to Windows, for example, the Compare-Object alias in PowerShell and others I could name, so you have a few options:

You can usually get around this by adding C:\Program Files\Git\usr\ to the path which contains all of the UNIX ports of functionality such diff, grep, awk, sed. You do have to be careful as some commands are used more commonly on Windows than others, the most common one is find, so be mindful of this.

A second option would be to fully qualify the call to diff by appending C:\Program Files\Git\usr\bin.

1 Like