user3692970
user3692970

Reputation: 41

Libraries not loading when running Rscript from PHP

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

Upvotes: 2

Views: 834

Answers (1)

user3692970
user3692970

Reputation: 41

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.

Upvotes: 2

Related Questions