Some R packages won't install

5,164

You need to install these build-dependencies for R-package:

sudo apt-get install r-base-dev

And then install R-packages to your home folder (that is ~/R/x86_64-pc-linux-gnu-library). You do not need to run RStudio as root.

Share:
5,164

Related videos on Youtube

Addem
Author by

Addem

Updated on September 18, 2022

Comments

  • Addem
    Addem over 1 year

    I have R version 3.4.2, trying to install ggplot2, ran install.packages("ggplot2", dependencies = TRUE) in RStudio. It eventually tells me it exited with non-zero exit status and the errors are hard to read because the message is so long, but I see that in the process Matrix was a dependency which also failed to install, so I try to directly install that, and here's what I see in the error message for that:

    /usr/bin/ld: cannot find -llapack
    /usr/bin/ld: cannot find -lblas
    /usr/bin/ld: cannot find -lgfortran
    collect2: error: ld returned 1 exit status
    /usr/share/R/share/make/shlib.mk:6: recipe for target 'Matrix.so' failed
    make: *** [Matrix.so] Error 1
    ERROR: compilation failed for package ‘Matrix’
    * removing ‘/usr/local/lib/R/site-library/Matrix’
    

    I'm not clear on what ld is at all and if I need to research that to solve this problem. It looks like it might alternately have something to do with Matrix.so.

    • N0rbert
      N0rbert almost 6 years
      You should not install R-packages system-wide. User per-user folders instead.
    • David Foerster
      David Foerster almost 6 years
      @user68186: The answers to the linked duplicate question recommend the installation of r-base-dev among others. This package depends on the packages that provide the development files for the missing libraries. It's a duplicate indeed.
    • Shubham Gupta
      Shubham Gupta over 3 years
      Make sure that package is using g++ or gcc and have the same version of fortran installed. gcc --version g++ --version and gfortran --version sudo apt install gfortran-8 My package used gcc. I have version 8.4.0
  • Addem
    Addem almost 6 years
    I installed r-base-dev and opened RStudio, then used install.packages and it works! Thanks! I wasn't really clear on how to install the packages to my home folder--I don't see a destination option. But I'm guessing it does this by default? Anyway, since it worked, I'm guessing it's fine.