libGL error when using SSH and X forwarding with MacOS

If you use MacOS and “ssh -X” or “ssh -Y” to access the cluster, and you see the following error messages when start a GUI application on the cluster:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Running the following command after starting a Slurm session may fix the problem: