[Rd] Best way for rgl's .onLoad to fail?

Bryan Hanson hanson at depauw.edu
Sun Jan 31 15:50:46 CET 2016


I think the 2nd option will be more palatable to inexperienced users, but both do state the important detail.   Bryan

> On Jan 30, 2016, at 4:11 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> 
> 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
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list