简体   繁体   中英

Why doesn't my `.Rprofile` run? (on unix server)

I have problems to start up my R session with a .Rprofile on a unix server. When I start an interactive job everything works fine. When I start a batch job, it doesn't (batch jobs are started through TORQUE and distributed across different nodes). I checked ?Startup but I still don't know what's going on. My .Rprofile contains a print(...) line just to make sure and I ran the test-job.r file below in batch mode. It tells me that I have a .Rprofile file at the current working directory and at the user directory (they are the same) and that it contains my print(...) code. So why is R not running the .Rprofile file on startup?

.Rprofile

print('Hallo World!')

test-job.r

profile1 = paste(getwd(),'/.Rprofile',sep='')
file.exists(profile1)
if(profile1) cat(readChar(profile1, 1e5))

profile2 = '~/.Rprofile'
file.exists(profile2)
if(file.exists(profile2)) cat(readChar(profile2, 1e5))

output

> file.exists(paste(getwd(),'/.Rprofile',sep=''))
[1] TRUE
> if(file.exists(paste(getwd(),'/.Rprofile',sep=''))) cat(readChar(paste(getwd(),'/.Rprofile',sep=''), 1e5))
print('Hallo World!')
> 
> 
> file.exists('~/.Rprofile')
[1] TRUE
> if(file.exists('~/.Rprofile')) cat(readChar('~/.Rprofile', 1e5))
print('Hallo World!')

From Intro to R :

note that R CMD does not of itself use any R startup files (in particular, neither user nor site Renviron files)

I interpret that as meaning BATCH mode doesn't read the .Profile file. If you want it, I guess you need to explicitly source it in test-job.r .

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