Scientific Computing

Disable Windows reporting modal

On Windows, program faults can cause an modal window to appear regarding reporting the issue to Microsoft. This window stops automated scripts from further progress. This is a problem for long-running programs or scripts that call other programs, perhaps on a Task Schedule.

modal Windows popup blocks programs restart

Disable Windows Reporting modal windows on Windows Pro and non-Pro by simply opening “services.msc” and disable “Windows Error Reporting Service”.

Windows Pro only

Alternatively, for Windows Pro:

Press +r and type

gpedit.msc

Go to Computer ConfigurationAdministrative TemplatesWindows ComponentsWindows Error Reporting and configure as desired.

Group Edit dialog

Reference

Flatpak open shell

Flatpak is a popular means to distribute software on Linux that installs and runs in a sandbox for each application. This is particularly useful when an application needs a newer GLIBC / GLIBCXX than the system has, which is often the case on RHEL and HPC systems.

It can be convenient to open a sandboxed shell in a Flatpak app’s sandbox. For example, to open a shell in the GNU Octave Flatpak sandbox:

flatpak run --command=sh org.octave.Octave

This can be useful to build further applications with CMake using a Flatpak program, for example CMake with GNU Octave.

Git apply patch line ending

Git patch files can be generated like:

git diff > my.patch

If the Git patch file is generated on a Windows computer and is copied to a non-Windows computer, the patch may fail to “git apply my.patch” on the non-Windows computer. If the mismatches seen with “git apply my.patch -v” show question marks “?” at the end of each line, the issue may simply be line endings mismatch.

Try fixing line endings in the patch file using dos2unix on the computer where the patch is to be applied:

dos2unix my.patch
git apply my.patch

dos2unix is installed like “brew install dos2unix” or “apt install dos2unix” or similar.

Git mv glob PowerShell

The git mv command tracks moves or renames of Git tracked files similar to the shell “mv” command. Typically it’s useful to “glob” match patterns of files to move to avoid extra typing. PowerShell command substitution is used with Get-ChildItem and “git mv”:

git mv $(gci -Path ./source_dir/ -Include *.cpp) ./dest_dir/

Find files with PowerShell

PowerShell can recursively find files like GNU Findutils using PowerShell function Get-ChildItem. The abbreviated form of Get-ChildItem is “gci”. Typically the “-Recurse” option is used as the default is to only search the specified directory level.

Examples:

Recursively find all “*.lib” files under directory ./build:

gci -Path build -Recurse -Filter *.lib

Find all files named “example.txt” under directory ~/projects:

gci -Path ~/projects -Recurse -Filter example.txt

Open all files found above in “code” Visual Studio code:

code (gci -Path ~/projects -Recurse -Filter example.txt)

Free ReactOS Windows clone in VirtualBox

ReactOS gives a free, open-source Windows XP API level replacement that can use USB devices. Sometimes Linux users need to use a Windows VM when USB devices are required in Windows programs. ReactOS can work in a VM for older Windows programs with a much smaller install than Microsoft Windows. As time goes on, less and less Windows software is compatible with Windows XP and hence less software is compatible with ReactOS.

Install ReactOS in a virtual machine with the VirtualBox version recommended in ReactOS install procedure. Create a new VM with name “ReactOS”, which should auto-populate needed settings.

When installing, use FAT file system instead of buggy, experimental BTRFS at this time. Disable JavaScript in ReactOS Firefox browser as ReactOS might hang at 100% CPU for JavaScript intensive websites. Type about:config in Firefox address bar and Toggle javascript.enabled to false.

ReactOS advantages vs. Windows:

  • ReactOS installation takes 90% less space than Windows
  • no OS license maintenance with free, open-source ReactOS
  • no licensing worries about making many copies of a working ReactOS install. Get a VM working and copy it to many workstations.
  • ReactOS theme feels like Windows XP, so there are few concerns about transitioning users reluctant to change

ReactOS Limitations:

ReactOS 0.4.x API level is Windows NT 5.2 (Windows 2003 / XP). Programs requiring Windows NT 6.0 (Vista) or newer will likely not run. Current versions of Python do not work with ReactOS 0.4.x due to the Windows NT 5.2 API level. Consider trying an older version of the program you want to install that is still noted to work with Windows XP when using ReactOS.

NT 6.x API Windows Vista support is important as many programs, including open source programs, have left Windows NT 5.x unsupported and non-functional for their programs.

Windows shared library caveats

In general on any project, “shared” libraries on Windows using .DLL files have numerous caveats that aren’t an issue on macOS and Windows due to decades-old stark differences in how Windows links and runs shared libraries. One key distinction is that Windows has no concept of Rpath as Unix-like OS have, which means the .DLL have to be on PATH environment variable for all shared libraries used in an executable. This can be a key drawback for Windows shared libraries in non-trivial projects using 3rd party libraries. In general we strongly recommend using “static” libraries on Windows, as the downsides of shared libraries on Windows are significant.

In the past year or so, GitHub Actions runners for Windows broke most “shared” library runs across projects. The projects would run in “shared” on physical Windows machines reliably, but not on CI. We have disabled Windows shared builds on GitHub Actions CI across all projects.

Windows Git symlinks

Windows Git requires one-time settings to enable Git symbolic links. If a computer doesn’t have these settings, it can create problems with inability to reset a Git repo, where the repo may have to be erased and re-cloned to fix. If an existing local Git repo on a Windows PC has problems with symbolic links, it may be necessary to re-clone the repo after first making these one-time settings.

Set Windows user permission to create symbolic links. Configure Git globally on the Windows PC to handle symlinks:

git config --global core.symlinks true

Git symlinks should only refers to paths within the Git repo. Where possible it is preferable to avoid symlinks, but this method above often works on Windows PCs for Git symlinks.