Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Alternative way to add rtools to PATH through .Renviron #26

Open
SamDeCraemer opened this issue Feb 26, 2021 · 3 comments
Open

Alternative way to add rtools to PATH through .Renviron #26

SamDeCraemer opened this issue Feb 26, 2021 · 3 comments

Comments

@SamDeCraemer
Copy link

I tried to install this on a home and work pc (both windows 10 64bit) using the instruction provided at https://cran.r-project.org/bin/windows/Rtools/. In both cases I simply installed rtools40 in the default directory c:/rtools40. While setting the PATH then worked like a charm on the former pc, I had a lot of trouble on my work pc. I managed to find a solution but adding a comment to suggest this alternative might save some other people time.

For the latter pc creating an .Renviron file running the suggested code below, then reloading rstudio and rended up adding "\usr\bin" instead of "c:\rtools40\usr\bin":
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

The same happened when trying to append the rtools40 path at the end of PATH by running
writeLines('PATH="${PATH};${RTOOLS40_HOME}\\usr\\bin"', con = "~/.Renviron")

I checked the makeconf file of the R installation ,and the RTOOLS40_HOME variable was correctly set to c:/rtools40. For some reason Rstudio(?) was not able to extract this information however. In the end, I solved the problem by manually entering the directory I installed rtools40 to using the code below, this might be a good suggestion for people having trouble:
writeLines('PATH="${PATH};C:\\rtools40\\usr\\bin"', con = "~/.Renviron")

Note: for some reason, trying to use the last snippet but adding the rtools40 path before the existing path caused the whole PATH variable to become corrupt:
#DONOTRUN writeLines('PATH="C:\\rtools40\\usr\\bin;PATH="${PATH}"', con = "~/.Renviron")

@jeroen
Copy link
Member

jeroen commented Feb 28, 2021

Hi thanks for your report. It looks like the RTOOLS40_HOME is not available, it should be set by the rtools40 installer. Did you install it under a different account name maybe?

What do you see in R:

Sys.getenv("RTOOLS40_HOME")

@SamDeCraemer
Copy link
Author

SamDeCraemer commented Mar 4, 2021 via email

@liuzhenqi77
Copy link

Can confirm having the same issue.

  • RTOOLS40_HOME is present on system env var, not user env var.
  • Sys.getenv("RTOOLS40_HOME") has value only when ran as admin.
  • manually changing the .Renviron file as suggested above solved the issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants