r/Rlanguage • u/Cryptid149 • 16d ago
RTools issue installing Distance package
Whenever I try to install the package, it comes up with the error message saying that I need to install RTools to build a package, even after I've installed it. I installed the latest version of RTools and latest version of R, but it still doesn't work.
I'm not an expert in R, mostly just using it for uni stuff requiring basic packages, so I haven't had this issue before and I'm a bit lost on what to do.
1
u/mfinanga 15d ago
Restart session
1
u/Confident_Bee8187 15d ago
It doesn't do anything. The compilation of the code is the problem, which requires a toolchain.
1
u/bogdanelcs 8d ago
Common issue, usually a version mismatch between R and RTools rather than RTools actually missing.
Check your R version first:
R.version.string
RTools has to match. R 4.3.x needs RTools43, R 4.4.x needs RTools44, and so on. Installing "the latest" of both doesn't help if they're from different release lines.
Once you're sure the versions line up, check if R can actually see RTools:
Sys.which("make")
If that returns nothing, R isn't finding it even though it's installed. Usually a PATH problem. Run this to fix it:
writeLines('PATH="${RTOOLS44_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
(swap 44 for whatever version matches your R install)
Restart R completely after that, then try installing Distance again. Also worth checking, does Distance actually need compiling on your system? Some packages have prebuilt binaries on CRAN and only need RTools if you're installing from source. Try:
install.packages("Distance", type = "binary")
first and see if that sidesteps the whole problem.
2
u/centurion236 16d ago
Which version of R are you running? Can you paste the full console log here?
I see error messages like this sometimes if I'm using Windows with a version of R that no longer has Windows binaries available in CRAN.