0

I'm calling from perl-cgi using

my $call = qx(Rscript tcga_analysis.R $bg_name $ctr_name $set $user);

when I use Rscript myRscript.R from unix on a server it works but from perl I can't seem to be able to load any package. I get the following error (from Apache log):

Error in library(gplots) : there is no package called 'gplots'

using .libPaths():

> .libPaths()
[1] "/home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1"
[2] "/usr/lib64/R/library"
[3] "/usr/share/R/library"

which shows my personal library in the home folder.

I tried using

library(gplots, lib.loc="/home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1")

but I get a lib.loc error saying that there is no library trees in there . I even created an .Rprofile file in the working directory containing the path to the library, but no success. I also tried to add pos=1 but with no success...

however, if I open R and call library(gplots) it works

I need to have it working calling Rscript from perl because it's part of an analysis pipeline that uses a web interface -> perl-cgi -> R to analyze some data!

thanks :)

TriRook
  • 147
  • 1
  • 3
  • 18
  • 2
    Is the cgi script run by a different user, maybe apache? Possibly a permission issue. – flodel Sep 06 '14 at 16:53
  • I am the owner of the var/www/html folder containing both R and perl cgi scripts – TriRook Sep 06 '14 at 16:54
  • It's the permissions of the R libraries that seem to be a problem. Try `chmod -R a+r /home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1`, i.e. make everything readable to anyone. – flodel Sep 06 '14 at 16:56
  • @flodel just tried, same error on the log: `Error in library(gplots) : there is no package called 'gplots'` – TriRook Sep 06 '14 at 17:02
  • Can you please provide the output of running `ls -ld /home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1/gplots` as yourself? – flodel Sep 06 '14 at 17:02
  • output is `drwxrwxr-x. 8 sbattaglia sbattaglia 4096 Sep 6 11:39 /home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1/gplots` ...which at my eyes says that permissions shouldn't be a problem – TriRook Sep 06 '14 at 17:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60754/discussion-between-flodel-and-trirook). – flodel Sep 06 '14 at 17:04

1 Answers1

0

I'm gonna post the answer that came up in the chat with @floded.

basically the libraries were in a folder on the server that were not visible to Apache. I re-downloaded the packages I needed in the location where the .R and .cgi files were, specified library(gplots, lib.loc="correctPathToLibrary") and it worked :)

TriRook
  • 147
  • 1
  • 3
  • 18