Paul Johnson | 15 Jun 2012 18:43
Picon

Windows suggestion: ask registry for location of Rterm.exe

I have a new idea on the "Rterm not found" problem that we see in
Windows sometimes. Ask the registry!

I wish I could do all this and show you the answer, but can't yet.
Before I forget what I've learned, I want to tell you, on the off
chance that this is an easy-ish problem for one of you.

The "Rterm not found" problem with Emacs-ESS is fairly frequent for
us.  Working with a class of 50 people, I suppose that 10-20 will have
trouble with Emacs-ESS because their R is not installed in the usual
place.  Emacs-ESS looks some places, but doesn't always find it. It
doesn't find Rterm.exe if we install R in C:\Program Files\R, for
example (no R version subdirectory).

I noticed that Rstudio and Notepad++(with NPPtoR) have no trouble
finding Rterm, no matter where it is installed.  So I started checking
into how those other editors do it, and the answer seems to be they
ask the registry for the newest R installation, unless user specifies
otherwise. It appears to me the registry access code in the batchfiles
project may be the most immediately relevant.

1. batchfiles

I learned of an R for Windows project called "batchfiles" which has
various idioms to find R by asking the registry.

https://code.google.com/p/batchfiles

I think it should be on the front of "runemacs" or such. It would run
every time Emacs-ESS starts, it would respect R_HOME in the user's
(Continue reading)

Rodney Sparapani | 15 Jun 2012 19:06
Picon
Gravatar

Re: Windows suggestion: ask registry for location of Rterm.exe

On 06/15/2012 11:43 AM, Paul Johnson wrote:
> 1. batchfiles
>
> I learned of an R for Windows project called "batchfiles" which has
> various idioms to find R by asking the registry.
>
> https://code.google.com/p/batchfiles
>
> I think it should be on the front of "runemacs" or such. It would run
> every time Emacs-ESS starts, it would respect R_HOME in the user's
> init.el file, but check registry optionally..
>
> The batchfiles are written in the Windows Command language (which I
> knew in 1994 or so:)). Here's what they do to find the R HOME. This
> idiom is used in several of their script files:
>
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> :: use environment variable R_HOME if defined
> :: else current folder if bin\rcmd.exe exists
> :: else most current R as determined by registry entry
> :: else error
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
>
> if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
> if not defined R_HOME for /f "tokens=2*" %%a in (
>   'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
>    ) do set R_HOME=%%~b
> if not defined R_HOME for /f "tokens=2*" %%a in (
>   'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL
> ^| findstr InstallPath'
(Continue reading)

Rodney Sparapani | 15 Jun 2012 20:53
Picon
Gravatar

Re: Windows suggestion: ask registry for location of Rterm.exe

On 06/15/2012 12:06 PM, Rodney Sparapani wrote:
> Hi Paul:
>
> Very nice thoughts. I'm just going to react to this part which seems
> to be the most straightforward. I think you can call this from elisp.
> But, the problem with this code is that it doesn't work, does it? Here's
> what I get on Windows XP:
>
> H:\>reg query hklm\software\R-core\R /v InstallPath
>
> Error: The system was unable to find the specified registry key or value
>
> H:\>reg query hklm\software\wow6432Node\r-core\r /v InstallPath
>
> Error: The system was unable to find the specified registry key or value
>
> What do you see?
>
> Rodney
>

Oh, hang on.  For me, I need

H:\>reg query hkcu\software\R-core\R /v InstallPath
! REG.EXE VERSION 3.0

HKEY_CURRENT_USER\software\R-core\R
     InstallPath REG_SZ C:\Documents and Settings\rsparapa.MCWCORP\My 
Documents\R\R-2.14.2

(Continue reading)


Gmane