How to fix R package installation fatal error: bzlib.h: No such file or directory

Problem:

While installing some R package, you see an error message like

cram/cram_io.c:57:10: fatal error: bzlib.h: No such file or directory
   57 | #include 
      |          ^~~~~~~~~
compilation terminated.

Solution:

You need to install the libbz2 development headers. On Ubuntu, you can do that using

sudo apt -y install libbz2-dev