Just run e.g. path/to/blender -b --python-expr "import bpy; bpy.ops.wm.addon_enable(module='space_view3d_math_vis')" (or even enable that add-on in userpref and try to start Blender 2.8 in background mode, I guess).
There are several level to that issue (and several ways to fix it, too, but that’s not my area of code so will live it to the experts ;) ):
- math_vis should absolutely not do what it does in first lines of its draw.py, calling gpu.shader.from_builtin() at module level, i.e. during init… tsst. This can be solved in many ways (not even sure it's worth storing in py those shaders? afaik this is cached internally anyway?), as long as it does not do any call outside of functions. Lazy init ftw!
- Think gpu module code (gpu_py_shader.c and friends) should ensure it has a valid OpenGL context blabla too? Unless add-ons are expected to do those checks themselves before using it?