[R] cron job install/update problems: tcltk can't find display (installing e.g., pbatR)

Paul Johnson pauljohn32 at gmail.com
Fri Jan 20 17:27:53 CET 2006


On Fedora Core Linux 4, I have a cron job that causes R to update all
packages and install new ones.  Lately, I notice in the log that some
packages fail to install.  These are ones that assume X is running. 
For example, the pbatR install requires tcltk to be loaded, and then
the install fails because in a cron job, there is no DISPLAY
environment.  I suppose the same happens if you try to install R
packages in the console, without X running?

Error output is pasted here.  I wonder if you can advise me whether
this is the kind of thing that can be fixed in the cron job or not. 
I've verified that pbatR does install interactively (because tcltk
does start).  If you think this is a pbatR-specific problem, i will
contact the author directly.  When I have the repos option set, the
interactive install does not cause any tcltk widgets to pop up, so I
wonder if it is really necessary.

* Installing *source* package 'pbatR' ...
** libs
g++ -I/usr/lib/R/include  -I/usr/local/include   -fPIC  -O2 -g -pipe
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4
-fasynchronous-unwind-tables -c wait.cpp -o wait.o
wait.cpp: In function 'int runCommands()':
wait.cpp:77: warning: ignoring return value of 'int system(const
char*)', declared with attribute warn_unused_result
g++ -shared -L/usr/local/lib -o pbatR.so wait.o   -L/usr/lib/R/lib -lR
** R
** save image
Loading required package: survival
Loading required package: splines
Loading required package: tcltk
Loading Tcl/Tk interface ... Error in fun(...) : no display name and
no $DISPLAY environment variable
Error: .onLoad failed in 'loadNamespace' for 'tcltk'
Error: package 'tcltk' could not be loaded
Execution halted
ERROR: execution of package source for 'pbatR' failed
** Removing '/usr/lib/R/library/pbatR'
** Restoring previous '/usr/lib/R/library/pbatR'
--------------------------------------------------------------

Here's the R code that runs from the Cron job

# Paul Johnson <pauljohn at ku.edu> 2005-08-31
# This should update and then install all packages, except for
# ones I exclude because they don't work or we don't want them.


#options(repos = "http://lib.stat.cmu.edu/R/CRAN/")
options(repos = "http://cran.cnr.berkeley.edu/")



#failPackages is the "black list".
# Things that don't build cleanly with FC4, but I
#  hope it will build someday soon.
failPackages <-
c("deldir","frailtypack","fSeries","fCalendar","fExtremes","fPortfolio","hmm.discnp","knncat","labdsv","survrec",
"SciViews","RGrace","uroot","fMultivar","fOptions","gcmrec","rcom","Rlsf")

#list of all currently installed packages
installedPackages <- rownames (installed.packages() )

#do any installed packages need removal because they are on the blacklist?
needRemoval <-  installedPackages %in% failPackages

# remove any blacklisted packages if they are already installed.
if (sum(needRemoval) >0)   remove.packages(installedPackages[needRemoval] )


#update the ones you want to keep
update.packages(ask=F, checkBuilt=T)

#get list of all new packages on CRAN
theNew <- new.packages()


#do any of the new packages belong to the black list?
shouldFail <- theNew %in% failPackages

#install non blacklisted packages that are in theNew list
if (sum(!shouldFail) > 0) install.packages( theNew[!shouldFail],dependencies=T)






--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas




More information about the R-help mailing list