From hanson at depauw.edu  Sun Jan 31 15:50:46 2016
From: hanson at depauw.edu (Bryan Hanson)
Date: Sun, 31 Jan 2016 09:50:46 -0500
Subject: [Rd] Best way for rgl's .onLoad to fail?
In-Reply-To: <56AD26EF.5000107@gmail.com>
References: <56AD26EF.5000107@gmail.com>
Message-ID: <8D38DD51-6E89-410C-AA46-107BB4762B91@depauw.edu>

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



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