Using R — Package Installation Problems

This entry is part 5 of 20 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:

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:


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:

And for bash:

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:

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:

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

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.:

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.

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.

5 Responses to Using R — Package Installation Problems

  1. Ben Bolker says:

    Other common problems (sorry, I don’t have the characteristic error messages for all of these):

    * package not available: same error as above, but may be caused by (1) trying to get packages from CRAN that actually live elsewhere (r-forge, rforge, github); (2) package has been withdrawn from CRAN/archived; (3) wonky repository
    * can’t reach repository: network problems (complete lack of connectivity, or firewall issues)
    * permissions problems: especially inability to write to library directory (supposed to be auto-detected and handled, but apparently doesn’t always work).

    It would be great to see a full decision tree for diagnosis and solutions …

    Also see the overlapping information in the R for Windows FAQ, and relevant questions on Stack Overflow (search for [r] package installation, e.g.: ; ;

  2. Pingback: Error installing R package e1071 | On the other hand

  3. Julia says:

    My issue is: Warning in install.packages(“data.table”): ‘lib = “C:/Program Files/R/R-3.1.1/library” ‘ is not writable.  So I gave it the option to put them somewhere else and that worked fine.  But when I tried using “data.table” I got: Error: could not find function “data.table”.  I figured it had put them in that alternative location so I moved them to the original library where it hadn’t let me put them.  Yet, I am still getting the error that it can’t find data.table.  Any help would be great.


  4. Rayd says:


    Please I need help

    I’m try install “marmap” in Ubuntu Trusty 32 bit using R –version 3.0.2 and just appear the

    The downloaded source packages are in

    How it’s possible to resolve this?


  5. Alex says:

    What about when the install.packages() command is pointed to an older version of the package than is found on CRAN?


    I tried downloading mvoutlier, which required sgeostat, and so I tried to use install.packages to get sgeostat, but the function is calling a version that is no longer listed on CRAN.


    Can I override this somehow?