Using R — Package Installation Problems

This entry is part 3 of 14 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.:

 

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 — Installing PackagesUsing R — Basic error Handing with tryCatch()Using R — Standalone Scripts & Error Messages
This entry was posted in R and tagged , . Bookmark the permalink.

2 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.: http://stackoverflow.com/questions/14382209/r-install-packages-returns-failed-to-create-lock-directory ; http://stackoverflow.com/questions/8818065/problems-with-installing-packages-to-r ;

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

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">