Even if you’ve installed the PostgreSQL client binaries via Brew (i.e., brew install postgres
), you will run into problems if you try to install the RPostgreSQL package in the usual way, i.e. install.packages('RPostgreSQL')
from the R console. That’s simply because there are no binaries on CRAN for Mavericks. If you look at http://cran.r-project.org/web/checks/check_results_RPostgreSQL.html you’ll see that OSX Mavericks is the only flavor that runs into problems building the package.
Fortunately the solution is trivial. Install it from source, and yes, this sounds way scarier than it really is.
Download the source tarball from http://cran.r-project.org/web/packages/RPostgreSQL/index.html. Now resist for a moment the urge to untar the file. Instead, install first the DBI package from the R console:
install.packages('DBI')
and then run this from the directory where you downloaded the tarball:
sudo R CMD INSTALL RPostgreSQL_0.4.tar.gz
And you’re ready to go.
2 thoughts on “How to install RPostgreSQL on OSX Mavericks”
Comments are closed.
it doesn’t work for me.
“/RS-PostgreSQL.h:23:14: fatal error: ‘libpq-fe.h’ file not found
include “libpq-fe.h””
If you’re under OSX you need to install PostgreSQL (see http://superuser.com/questions/296873/install-libpq-dev-on-mac-os):
If you’re under some Linux flavor you need the
libpq-dev
package (http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem):