简体   繁体   中英

Can't load R library on server using Rscript command

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 :)

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM