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

install_bz2_dev.sh
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

example.sh
sudo apt -y install libbz2-dev

 


Check out similar posts by category: R