Post

How to Resolve Tidyverse Installation Issues on Ubuntu 22

When installing the tidyverse package in R on a newly installed Ubuntu 22 system, users often encounter errors related to missing system dependencies. This post provides a concise guide on how to resolve these issues, ensuring a smooth installation.

Why Does This Happen?

The tidyverse package in R requires several dependencies that are not pre-installed on most Linux distributions, including Ubuntu. Particularly, the textshaping package, which is a dependency of tidyverse, needs the harfbuzz and fribidi libraries to function. These libraries handle complex text layouts and bidirectional text respectively, and are crucial for correctly displaying text within graphical outputs generated by R.

When these libraries are absent, textshaping fails to install, which in turn prevents the installation of tidyverse. The errors often manifest during the installation as missing file notifications or unmet dependency alerts.

Step-by-Step Solution

To successfully install tidyverse on Ubuntu 22, follow these steps:

  1. Install Required Libraries: Open your terminal. You need to install harfbuzz and fribidi, which are essential for the textshaping package. Execute the following command:

    1
    2
    3
    
     sudo apt-get update
     sudo apt-get install libharfbuzz-dev libfribidi-dev
        
    

    This command updates your package lists and installs the necessary libraries.

  2. Verify Library Path (Optional): If R still does not recognize the installed libraries, you might need to set the PKG_CONFIG_PATH environment variable. This step is typically not required, but if needed, locate your .pc files (usually in /usr/lib/x86_64-linux-gnu/pkgconfig) and set the variable:

    1
    2
    
     export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
        
    

    This ensures R can locate the pkg-config files of the installed libraries.

  3. Install Tidyverse: Once the system dependencies are in place, go back to R and install tidyverse by running:

    1
    2
    
     install.packages("tidyverse")
        
    

Following these steps should resolve any issues related to tidyverse installation on Ubuntu 22 by addressing the missing system dependencies. This method ensures that all underlying libraries needed by the tidyverse packages are correctly installed and recognized, allowing you to leverage the powerful data manipulation and visualization capabilities of tidyverse in your R environment.

This post is licensed under CC BY 4.0 by the author.