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

Problem:

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

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

Solution:

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

sudo apt -y install liblzma-dev