[R] Add a third .libPath

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Dec 2 16:20:16 CET 2020


You are mixing up two different things.

The .libPaths() function returns paths where R searches for R packages.

Rtools is not an R package, it is a collection of utilities and support 
files to run in Windows.

For Rtools to be found, you need to add it to the Windows PATH variable, 
not to .libPaths().  You can see the current value of PATH by running 
this in R:

Sys.getenv("PATH")

This will give a long string variable with various directories separated 
by semicolons.  You want to make sure it contains the Rtools40 
executable directory (typically "C:/Rtools40/usr/bin", though for you it 
might be "\\\\gold/home/ndw003/reichmjs/MyDocs/R/rtools40/usr/bin").  If 
it doesn't (which would cause has_rtools() to fail, so I'll assume it's 
not in yours) you can add it temporarily using

Sys.setenv(PATH = paste(Sys.getenv("PATH"), 
"\\\\gold/home/ndw003/reichmjs/MyDocs/R/rtools40/usr/bin", sep = ";"))

For a permanent addition you need to edit the system PATH setting.  You 
should probably ask an admin to do that for you.

Duncan Murdoch


On 02/12/2020 9:14 a.m., Jeff Reichman wrote:
> r-help Forum
> 
>   
> 
> My employer has not yet approved R/RStudio but has allowed me to run
> R/RStudio from profile.  I need to add RTools but not sure I can run RTools
> from the same location.
> 
> So I unzipped Rtools and added the folder to my profile location containing
> R and RStudio and then modified my Rprofile adding a third path to the
> RTools folder as follows:
> 
>   
> 
> # my custom stuff
> 
> myPaths <- c(.libPaths(), "\\\\gold/home/ndw003/reichmjs/MyDocs/R/rtools40
> <file://gold/home/ndw003/reichmjs/MyDocs/R/rtools40> ")
> 
> .libPaths(myPaths)
> 
>   
> 
> Not sure if this is the best method but seems to work;
> 
>   
> 
>> .libPaths()
> 
> [1] "\\\\gold/home/ndw003/reichmjs/MyDocs/R/win-library/4.0
> <file://gold/home/ndw003/reichmjs/MyDocs/R/win-library/4.0> "
> 
> [2] "\\\\gold/home/ndw003/reichmjs/MyDocs/R/R-40.3/library
> <file://gold/home/ndw003/reichmjs/MyDocs/R/R-40.3/library> "
> 
> [3] "\\\\gold/home/ndw003/reichmjs/MyDocs/R/rtools40
> <file://gold/home/ndw003/reichmjs/MyDocs/R/rtools40> "
> 
>   
> 
> except when I run
> 
>   
> 
>> has_rtools()
> 
> WARNING: Rtools is required to build R packages, but is not currently
> installed.
> 
>   
> 
> Please download and install Rtools 4.0 from
> https://cran.r-project.org/bin/windows/Rtools/.
> 
>   
> 
> I am assuming R isn't seeing Rtools
> 
>   
> 
> So can I run Rtools from the same profile location as R and RStudio? IF so
> what do I need to do?
> 
>   
> 
> Jeff Reichman
> 
>   
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list