From ripley at stats.ox.ac.uk  Sun Nov 30 12:14:22 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sun Nov 30 12:14:13 2003
Subject: [Rd] R as OS X Framework
In-Reply-To: <x2ekvq2jhk.fsf@biostat.ku.dk>
Message-ID: <Pine.LNX.4.44.0311301110120.31503-100000@gannet.stats>

On 30 Nov 2003, Peter Dalgaard wrote:

> Prof Brian Ripley <ripley@stats.ox.ac.uk> writes:
> 
> > On Sat, 29 Nov 2003, Simon Urbanek wrote:
> > 
> > > The current R needs R_HOME to be set before using it even in its 
> > > embedded form. Now this defeats the idea of location independence of 
> > > the framework. The application doesn't have to care whether the 
> > > framework is in /Library/Frameworks, ~/Library/Frameworks or any 
> > > user-defined framework location. Therefore it would be nice to have a 
> > > tiny function in the R shlib, that would tell me where the shlib lives 
> > > (either by using system's API to determine its own location, or at 
> > > least the path used on installation).
> > > 
> > > BTW: This is not Mac specific - I was fighting this on Windows (and 
> > > unix for that matter) as well - it is possible to run an .exe linked to 
> > > R.dll from anywhere, if R.dll is in the PATH. But then, one has to 
> > > determine R_HOME somehow (yes, there is the registry, but that's not 
> > > really safe if more R versions are installed).
> > 
> > How do you do that?  For R's own executables on Windows R_HOME is
> > determined from where they are loaded from.  You cannot AFAIK determine
> > from within an executable where the R.dll was linked from.  That's why the
> > rproxy.dll uses the registry.  I believe you have even less information on 
> > Windows.
> 
> ..than on Windows? Did you mean Unix there? 

Yes, sorry, `than' was missing.  I meant on MacOS X.

> Finding the full path name of the current executable is a well-known
> impossible under Unix (there's no enforced relation between the
> executable and what goes in argv[0]). Doesn't keep applications from
> trying anyway, and mostly succeeding. E.g. Tcl has Tcl_FindExecutable.

But it is not the executable's but the DLL's full path that it is used to 
find R_HOME.  On Windows you could in principle find loaded occurrences of 
R.dll, but I don't know how to do that on Unix (and it is a lot less 
likely to be unique).

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] R as OS X Framework
Prof Brian Ripley