1

I am trying to install PL/R 8.3.0.13.1 on my MacBook Pro running OS X 10.7.5, Postgres 9.2 and R 2.15.2. I have found on the web a nice step-by-step guide for Windows but I can't find anything similar for Mac.
I got stuck when I run this command [as official documentation] ( http://www.joeconway.com/plr/doc/plr-install.html ):

USE_PGXS=1 make

Output:

make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found

*** Cannot build PL/R because R_HOME cannot be found.
*** Refer to the documentation for details.

Clearly that means I need to create somehow R_HOME, variable and/or location...

Any idea how to do it?

IRTFM
  • 258,963
  • 21
  • 364
  • 487
CptNemo
  • 6,455
  • 16
  • 58
  • 107
  • That guide at your second link doesn't look like a Windows specific guide, although it does have a small Win32 paragraph. I think you need to describe the earlier operations and the directory location before people will know what your setup really is. You especially need to say what version of XCode you are using and how you set your environment variables. – IRTFM Jan 23 '13 at 22:58
  • My XCode version is 4.5.2. What I did so far is to download PL/R source (http://www.joeconway.com/plr/plr-8.3.0.13.1.tar.gz) and untar it in the "Downloads" folder. Then from the terminal I run the command above and obtained that output. I am sorry but I have no idea how to set my environment variables. I don't think I ever did it. – CptNemo Jan 23 '13 at 23:42
  • Rather than do this in comments you should delete it and paste that into the question. The directions on those pages specified setting environment variables, so you may need to look up (or ask questions with a macos tag) how to do that. The error is telling you that the PLR R_HOME environment variable cannot be found. – IRTFM Jan 23 '13 at 23:53

2 Answers2

1

The error message is actually a bit confusing. If you look at the Makefile of PL/R, the logic is that it uses R_HOME to find R when set, otherwise it tries pkg-config. You have neither set, so it bails out.

I recommend going the pkg-config route if possible. The R_HOME route appears to assume an R installation scheme that might not be universally applicable. Perhaps it applies to builds straight from source.

The above applies to all platforms. Now on OS X, it depends on how you installed R. For example, if you used MacPorts, it would go something like this:

sudo port install pkgconfig
sudo port install R

and then build PL/R itself:

make USE_PGXS=1

But that will break because PL/R does not expect that MacPorts separates the R headers into two separate directories (architecture-dependent and -independent I suppose).

Homebrew might work better, but the principle is the same.

Peter Eisentraut
  • 35,221
  • 12
  • 85
  • 90
0

You need to figure out what you should set your PLR environment R_HOME variable. In a terminal session I get this

computername:~ username$ R RHOME      #only enter stuff after"$"
/Library/Frameworks/R.framework/Resources

This is at the bottom of that page you linked to:

"Tip: R_HOME must be defined in the environment of the user under which PostgreSQL is started, before the postmaster is started. Otherwise PL/R will refuse to load. See plr_environ(), which allows examination of the environment available to the PostgreSQL postmaster process. "

This is from a webpage describing the problem and offering a fix:

To fix: Add a "R_HOME = '/usr/lib/R' " to /etc/postgresql/version/cluster/environmen

Example Fix for version 8.1:
 $ sudo -s
 # echo -e "\nR_HOME = '/usr/lib/R'" >> /etc/postgresql/8.1/main/environment
 # exit

To Test:
 $ sudo /etc/init.d/postgresql-8.1 restart
 $ sudo -u postgres psql plr_test
 plr_test=# select test();
  test
 ------
IRTFM
  • 258,963
  • 21
  • 364
  • 487