Gorjanc Gregor
2008-Jul-18 07:13 UTC
[Rd] Windows: adding R/bin folder to the PATH variable
Hi! Under Windows R is installed, but its bin folder is not added to the system PATH variable. I know that this is handled properly under *nix like systems and I wonder, why this is not the default also for the MS Windows? I guess that for most users a shortcut on the desktop or anywhere else is sufficient, but there are occasions when one expects to able to lunch R from anywhere - say the Command prompt. Regards, Gregor
Prof Brian Ripley
2008-Jul-18 08:18 UTC
[Rd] Windows: adding R/bin folder to the PATH variable
On Fri, 18 Jul 2008, Gorjanc Gregor wrote:> Hi! > > Under Windows R is installed, but its bin folder is not added to the > system PATH variable. I know that this is handled properly under *nix > like systems and I wonder, why this is not the default also for the MS > Windows? I guess that for most users a shortcut on the desktop or > anywhere else is sufficient, but there are occasions when one expects to > able to lunch R from anywhere - say the Command prompt.This is the normal behaviour of Windows applications. There are several reasons, including length limits on the Windows PATH (which are version-specific) and that shells are not normally used -- most Unix shells hash the path contents so lookup is (almost) independent of the number of applications on the path. If you run a shell (e.g. the Command prompt) you can set the path for that shell, and indeed I have my system setup to use a different path in shells than used from the desktop). Finally, those Windows installers that do add to the PATH frequently fail to uninstall correctly. -- Brian D. Ripley, ripley at 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
Gorjanc Gregor
2008-Jul-18 09:50 UTC
[Rd] Windows: adding R/bin folder to the PATH variable
>> Under Windows R is installed, but its bin folder is not added to the >> system PATH variable. I know that this is handled properly under *nix >> like systems and I wonder, why this is not the default also for the MS >> Windows? I guess that for most users a shortcut on the desktop or >> anywhere else is sufficient, but there are occasions when one expects to >> able to lunch R from anywhere - say the Command prompt. > > This is the normal behaviour of Windows applications. There are several > reasons, including length limits on the Windows PATH (which are > version-specific) and that shells are not normally used -- most Unix > shells hash the path contents so lookup is (almost) independent of the > number of applications on the path. > > Finally, those Windows installers that do add to the PATH frequently fail > to uninstall correctly.I was not aware about this relevant issues. I understand now why changing the PATH variable is not so common. Perhaps, the following scheme might work better 1. Set the R_BIN variable - something like R_BIN=.../R/R-*/bin 2. Add the R_BIN variable to PATH variable - something like PATH=...;%R_BIN% Though I can see problems with multiple versions etc. Regards, Gregor
Gabor Grothendieck
2008-Jul-18 10:16 UTC
[Rd] Windows: adding R/bin folder to the PATH variable
On Fri, Jul 18, 2008 at 4:18 AM, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:> On Fri, 18 Jul 2008, Gorjanc Gregor wrote: > >> Hi! >> >> Under Windows R is installed, but its bin folder is not added to the >> system PATH variable. I know that this is handled properly under *nix like >> systems and I wonder, why this is not the default also for the MS Windows? I >> guess that for most users a shortcut on the desktop or anywhere else is >> sufficient, but there are occasions when one expects to able to lunch R from >> anywhere - say the Command prompt. > > This is the normal behaviour of Windows applications. There are several > reasons, including length limits on the Windows PATH (which are > version-specific) and that shells are not normally used -- most Unix shells > hash the path contents so lookup is (almost) independent of the number of > applications on the path. > > If you run a shell (e.g. the Command prompt) you can set the path for that > shell, and indeed I have my system setup to use a different path in shells > than used from the desktop). > > Finally, those Windows installers that do add to the PATH frequently fail to > uninstall correctly. >There are two other problems, as well: - you might want to use two different versions of R on the same computer - the directory that normally resides at c:\rtools\bin contains a find command which conflicts with the Windows find command so if you keep rtools\bin in your path it can cause other Windows scripts to fail. At any rate, note that batchfiles at http://batchfiles.googlecode.com has Rcmd.bat, R.bat, Rgui.bat, etc. that you just place anywhere in your path and they will automatically find R and rtools from the registry and MiKTeX via a heuristic and then launch the corresponding R .exe . Just place one of them or all of them anywhere in your path in which case no path changes are required to run R or to build R packages at all. They also have the advantage that if you use them you can be sure that the temporary PATH that they set up and remove on the fly gets set properly which is an advantage since, based on messages on r-help or r-devel, wrong setting of PATH is a frequent problem.