[Rd] Best way for rgl's .onLoad to fail?
Duncan Murdoch
murdoch.duncan at gmail.com
Sat Jan 30 22:11:11 CET 2016
On OSX and Linux, the rgl package currently requires X11 libs to be
available for linking. Recent versions of OSX don't include them by
default, so I'd like rgl to fail nicely.
Ideally, it will load a library that doesn't need to link to the X11
libs but will still allow WebGL code to work, but that's complicated, so
I'd like a stopgap.
I can detect that the failure is about to happen, and call stop() in the
.onLoad hook, but that gives an ugly message:
> library(rgl)
Error : .onLoad failed in loadNamespace() for 'rgl', details:
call: NULL
error: X11 not found; XQuartz (from www.xquartz.org) is required to
run rgl.
Error: package or namespace load failed for ‘rgl’
Alternatively, I can just give a warning and not attempt to load the rgl
lib:
> library(rgl)
Warning message:
X11 not found; XQuartz (from www.xquartz.org) is required to run rgl.
rgl is now loaded, but it doesn't work; just about any function call
will give an error, e.g.
> plot3d(1,2,3)
Error in rgl.cur() : object 'rgl_dev_getcurrent' not found
Do people have opinions about this?
One comparable package is RGtk2: if Gtk2 isn't install, it offers to
install it. I could probably do that for XQuartz. If the user says no,
RGtk2 gives really ugly error messages. rgl can work without XQuartz,
but as I already mentioned, making this work is complicated, so I'd like
something simple for now.
Duncan Murdoch
More information about the R-devel
mailing list