2

I am trying to run an R script from PHP.

My PHP file looks like this:

exec("Rscript fig_lollipop.r");

And my R script looks like this:

library('RPostgreSQL')
#more goes code here...

I keep getting the following error:

Error in library("RPostgreSQL"):There is no package called 'RPostgreSQL'

I have attempted searching for common answers to this, and I think it might be related to the www-data user, but I'm really not sure. The R script works fine when running from the terminal.

Thanks in advance for any help! RC

  • I forgot to mention that I am working on Ubuntu 12.04. – user3692970 May 30 '14 at 22:25
  • Can you change your script to show the value of `.libPaths()` for that session so that you know the web user can see the package? Do they have permissions to read those files? – MrFlick May 30 '14 at 22:44
  • 1
    The `.libPaths()` command in the terminal revealed an additional folder (where all the relevant packages are stored), as compared to `.libPaths()` from the web app. I copied the needed packages to a folder listed in `.libPaths()` from the web app, and now everything works. Thanks for the advice! – user3692970 Jun 10 '14 at 20:39

1 Answers1

2

I ran the .libPaths() command in the terminal, and discovered an additional folder (where all of the relevant packages are stored), as compared to the .libPaths() command run from the web app. I ended up copying relevant packages to a folder listed in the web app .libPaths(), and everything works now.

Thanks to "MrFlick" for the advice! I'm a newbie to this stuff, and thought that packages were installed for all users.