Using R — Package Installation Problems

This entry is part 5 of 21 in the series Using R

The post titled Installing Packages described the basics of package installation with R.  The process is wonderfully simple when everything goes well.  But it can be maddening when it does not.  Error messages give a hint as to what went wrong but do not necessarily tell you how to resolve the problem.  This post will collect some of the error messages we’ve encountered while installing R packages and describe the reasons for the error and the workarounds we’ve found.

1) Older version of R

Warning message:
In install.packages(c("sp")) : package ‘sp’ is not available

This is the message that you get when the CRAN package you’re interested in requires a more recent version of R than you have.  Remember, the default behavior of install.packages() is to grab the latest version of a package.

In this case you have to poke around in the “Old sources” link on the CRAN page for that package and use trial-and-error to find an older version of the package that will work with your version of R.  You should start by determining what version of R you have:

R --version
  R version 2.8.1 (2008-12-22)

This version of R was released at the end of 2008 and any version of the “sp” package released in 2008 should work. At least some of the 2009 releases should also work. Perusing the sp archive, we might try installing version 0.9-37, the last of the 0.9-3x series which was released in May of 2009:

sudo CMD INSTALL sp_0.9-37.tar.gz
  # Success!


2) Unable to execute files in /tmp directory

ERROR: 'configure' exists but is not executable -- see the 'R Installation and Administration Manual'

By default, R uses the /tmp directory to install packages.  On security conscious machines, the /tmp directory is often marked as “noexec” in the /etc/fstab file.  This means that no file under /tmp can ever be executed.  Packages that require compilation or that have self-inflating data will fail with the error above.  One such package is RJSONIO.

The solution is to set the TMPDIR environment variable which R will use as the compilation directory. For csh shell:

mkdir ~/tmp
setenv TMPDIR ~/tmp

And for bash:

mkdir ~/tmp
export TMPDIR=~/tmp

If you have this problem while you’re trying to sudo install a package into the system libraries, you can first install the package into your personal library and then copy the compiled package over to the system library directory:

sudo cp -r ~/R/x86_64-pc-linux-gnu-library/2.15/Cairo/ /usr/local/lib/R/site-library/

3) Unable to locate system libraries

No package 'fftw3' found

Assuming you are certain you have installed the ‘missing’ library, this can be indicative of installation in a non-standard location. The R package you are installing may offer additional information on environment on how to educate the compiler about the location of variables.

In the case of the fftw package that generated this error, the complete interaction was:

sudo R CMD INSTALL fftw_1.0-3.tar.gz
No package 'fftw3' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

The solution is to specify the suggested environment variable with ‘–configure-vars’:

sudo R CMD INSTALL --configure-vars="PKG_CONFIG_PATH=/usr/local/lib/pkgconfig" fftw_1.0-3.tar.gz

4) Binary package compiled with different version of R

Warning message:
package ‘ncdf’ was built under R version 3.0.2

By default, R will install pre-compiled versions of packages if they are found. If the version of R under which the package was compiled does not match your installed version of R you will get the message above.

The solution is to download the package source and install by hand with e.g.:

R CMD INSTALL ncdf_1.6.6.tar.gz

5) Binary package compiled with different version of library

Error in readPNG(tmp) : unable to initialize libpng
In addition: Warning message:
In readPNG(tmp) :
libpng warning: Application built with libpng-1.6.16 but running with 1.5.17

The readPNG() problem popped up with folks running OS X who installed R with MacPorts. Both R and the png package on CRAN were compiled against a different version of the system-wide limping than the MacPorts version of R.

The solution is to deactivate the port version of R and install it from download. Then reinstall the png package.

sudo port deactiveate R

Use “deactivate R@3.3.2” or similar if a specific version is installed. Then install R from CRAN. Finally, use RStudio to remove the png package and re-install it. Restart RStudio one more time and it should work.

Other problems

Please leave comments describing other package installation problems and solutions you’ve encountered to help us build a more complete listing.


Series NavigationUsing R — Basic error Handing with tryCatch()Using R — Easier Error Handling with try()
This entry was posted in R and tagged , . Bookmark the permalink.

Comments are closed.