Install two versions of rtools - r

I have R version 4.0.2 and Rtools40 installed in windows on the local disk C:\. I recently installed Microsoft R Client version 3.5.2, in the local disk E:\. My question is how can I install Rtools35.exe on the E:\ disk without interfering with the Rtools40 variable environment?. In other words, I want to have both versions of rtools and that they work without problems, Thanks.
When switching to R 3.5.2, rtools does not work.
library(Rcpp);
evalCpp("2 * M_PI")
Error in system(cmd, intern = !showOutput) : 'E:/Program' not found
Error in system(cmd, ignore.stderr = TRUE, intern = TRUE) :
'E:/Program' not found
R 4.0.2 works
library(Rcpp);
evalCpp("2 * M_PI")
6.283185

Read the instructions at this page It should not be too hard to set up your two installation of R (4.0 and 3.6.X) so that each one queries a different .Renviron file and thus sets up a different path to the desired Rtools repository.

The problem was due to the fact that Microsoft R Client version 3.5.2, was installed in a path with space E:\Program Files\Microsoft\R Client, it was solved by installing it in a path without spaces E:\Microsoft\R-Client, such as suggested in: Message error 'C:/Program' not found with Rcpp

Related

Rtools not found by R when installing packages from CRAN

When install any new package I get errors saying Rtools is not found. I followed the manual install instructions for Rtools but still get the same error message.
> install.packages("phyloseq")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding
It seems R is not finding Rtools. Is there anyway to fix this?
I have noticed a second issue of previously installed packages disappearing also when starting new R sessions. Could these two issues be linked?
My R version in 4.0 and I am working in Windows 64bit
After installation is complete, you need to perform one more step to be able to compile R packages: you need to put the location of the Rtools make utilities (bash, make, etc) on the PATH. The easiest way to do so is create a text file .Renviron in your Documents folder which contains the following line:
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
Now restart R, and verify that make can be found, which should show the path to your Rtools installation.
Sys.which("make")
## "C:\\rtools40\\usr\\bin\\make.exe"
https://cran.r-project.org/bin/windows/Rtools/
The second part with packages not being found has to do with upgrading the R version e.g. 3.5 to 3.6 or 3.6 to 4.0. If you go to Documents\R\win-library there will be a version folder with the libraries installed inside. Here is a script that will install the old libraries.
lib_loc <- "C:/Users/apdev/Documents/R/win-library/3.3"
to_install <- unname(installed.packages(lib.loc = lib_loc)[, "Package"])
to_install
install.packages(pkgs = to_install)
https://community.rstudio.com/t/reinstalling-packages-on-new-version-of-r/7670/4

Rtools 3.5 not recognized?

I just installed R3.5 (and RStudio) on a new computer that has not previously had R on it. I then installed the devtools package, and when I went to install a package off of github, I realized (when prompted!) I had forgotten to install Rtools, so I followed the prompts to do so. Interestingly, this R tools installed to the directory of C:\RBuildTools by default and with no prompts for setting path variables as I had recalled in previous versions.
When I reloaded R, I was prompted to install Rtools again. My path contained no reference to Rtools (or the Rbuildtools directory), and remembering that my past installations had used the dir C:\Rtools, I decided to uninstall C:\RBuildTools and installed a fresh version off http://cran.r-project.org/bin/windows/Rtools/ ( installed version 3.5) into C:\Rtools. In installation I had the path variable option checked.
I reloaded RStudio and checked to make sure Rtools was found:
> devtools::find_rtools()
Error in system(full, intern = TRUE, ignore.stderr = quiet, ...) : running command '"C:/PROGRA~1/R/R-35~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD config CC' had status 2
However, rtools appears in my PATH:
> Sys.getenv("PATH")
[1] "C:\\Program Files\\R\\R-3.5.0\\bin\\x64;C:\\Rtools\\bin;..."
So this doesn't appear to be an issue with Rtools not being added properly to my Path variable. Google searches have turned up seemingly related errors but nothing so far that solves my issue. I have tried both suggestions here and neither have worked. I wonder if this could be related to RStudio.
I had a similar problem with RTools 3.5.
The installer did add C:\RTools\bin to the PATH, but it did not add
C:\RTools\mingw_64\bin which apparently did cause some confusion.
After adding C:\RTools\mingw_64\bin to the PATH, everything was fine.
My symptoms were a bit different though: RStudio reported an error when trying to "Install and Restart" my package that RTools were not found, while devtools::find_rtools() reported them to be present.
I have a comprehensive answer here for rtools not being recognized thru use of pkgbuild
`devtools::install_github(repo)` keeps installing rtools35.exe
The code snippet acknowledges the github comment this is posted (helped by r-sig-finance citizens)
However, (I can't comment) the error of find_tools() has disappeared but remains in devtools::install_bitbucket() for the new code that was the ultimate target and is in a src/master on BB cloud.
I unloaded the devtools and installed with remotes
unloadNamespace("devtools")
library(remotes)
install_bitbucket(author/repo)
As I said the problem with find_tools is taken care of by pkgbuild loading all items
Try updating RStudio to the latest version.
I had this problem after updating Rtools to 3.5 and found that updating RStudio to 1.1.447 fixed it.
If that doesn't work, Can you run rstudioapi::versionInfo()$version from inside RStudio and share the output?
If this isn't your problem I found that RStudio keeps a log - and it helped me isolate this issue. In my case the file was located in, "C:\Users\my_windows_username\AppData\Local\RStudio-Desktop\log\rsession-my_windows_username.log"
I found this warning in the log time that corresponed to the error in RStudio
WARNING Unknown Rtools version: 3.5; LOGGED FROM: rstudio::core::Error rstudio::core::r_util::scanRegistryForRTools(HKEY, bool, std::vector*) C:\Users\Administrator\rstudio\src\cpp\core\r_util\RToolsInfo.cpp:269
This indicated that RStudio didn't recognize 3.5, which led me to check for an updated version of RStudio.

R unable to load internet routines after upgrade to MacOS Sierra

When running R after upgrading my mac to 10.12.6 (Sierra), R can no longer load libraries or access anything on the internet:
> install.packages("devtools")
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/anaconda/lib/R/doc/CRAN_mirrors.csv'
[...]
Warning: unable to access index for repository
https://cran.cnr.berkeley.edu/src/contrib:
internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/anaconda/lib/R/modules//internet.so':
dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: #rpath/libssh2.1.dylib
Referenced from: /anaconda/lib/R/modules//internet.so
Reason: image not found
2: package ‘devtools’ is not available (for R version 3.4.1)
Similarly:
> source("https://bioconductor.org/biocLite.R")
Error in file(filename, "r", encoding = encoding) :
internet routines cannot be loaded
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
unable to load shared object '/anaconda/lib/R/modules//internet.so':
dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: #rpath/libssh2.1.dylib
Referenced from: /anaconda/lib/R/modules//internet.so
Reason: image not found
This happens both when I run R from Terminal and when I run R from RStudio (though RStudio only gives me the error, not the warning, and then still fails).
I found other people with vaguely similar problems in the past; one common solution was to re-install XQuartz, which I have done, but which didn't help.
Another common solution was to update LD_LIBRARY_PATH. However, 'libssh2.1.dylib' does not seem to exist: 'locate libssh2.1.dylib' returns nothing. I did find libssh2.dylib in /Applications/Xcode.app/Contents/Developer/usr/lib/libssh2.dylib, which is presumably the same thing, but R isn't finding it, I suppose.
Any ideas? Thank you!
EDIT: I found a simple solution. Just download the .tar file and use the command 'R CMD INSTALL mcmcse_1.3-2.tar', for example, in your terminal, from the directory in which your .tar file is saved.
I think that install.packages(‘package_name’) not working within R on macOS Sierra (with the package manager Anaconda installed) might be because Anaconda moves R’s path.
Just a reply to flag the same issue while using Anaconda 4.2.0 with R 3.4.1 on macOS Sierra 10.12.6. I was initially running R 3.4.0 in /usr/bin/R, but R has since become R 3.4.1 in /Users/[username]/anaconda/bin/R after installing Anaconda 4.2.0.
Warning: unable to access index for repository https://www.stats.bris.ac.uk/R/src/contrib:
internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so':
dlopen(/Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so, 6): Library not loaded: #rpath/libssh2.1.dylib
Referenced from: /Users/michaelfaulknerlocal/anaconda/lib/R/modules//internet.so
Reason: image not found
2: package ‘mcmcse’ is not available (for R version 3.4.1)
This turns out to be, as far as I can tell, a bug in Anaconda2-4.4.0-MacOSX-x86_64.pkg I had an anaconda/ directory in /, /Applications/, and /Users/[me]/: I deleted all of them, and removed the Anaconda PATH change to .bash_profile. R then reverted to /usr/local/bin/R, which did not have the internet connection problems reported above. Then I reinstalled Anaconda from scratch, then installed RStudio from Anaconda-Navigator. 'which R' now pointed at /Users/[me]/anaconda/bin/R (the PATH having changed again upon install), and which had the internet connectivity problem. Running /usr/local/bin/R directly, even with Anaconda installed, had no problems.
I've filed the bug as https://github.com/Anaconda-Platform/support/issues/137 but now can at least run R myself by using /usr/local/bin/R.

R cmd check not locating texi2pdf on mac after R 3.1.3 upgrade

Does anyone have a link to clear instructions on how to install and configure the necessary latex packages to build R packages on a mac?
I have some scripts for building and checking R packages on a mac server. They seemed to work fine, but after upgrading to R 3.1.3, many of the packages started failing with
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'networkVignette.tex' failed.
Messages:
sh: /usr/local/bin/texi2dvi: No such file or directory
Calls: <Anonymous> -> texi2pdf -> texi2dvi
Execution halted
I found a thread which seemed to suggest I need a more recent version texinfo (5.2) than what is installed by default. And apparently I've I've got the wrong version installed in the wrong location?
which texi2pdf
/sw/bin/texi2pdf
texi2pdf --version
texi2pdf (GNU Texinfo 5.1) 5234
(same version is reported when running system('texi2pdf --version') in R )
This thread gives a link to a texinfo 5.2 source collection:
http://r.789695.n4.nabble.com/R-CMD-build-looking-for-texi2dvi-in-the-wrong-place-R-devel-td4701706.html
But I'm not familiar with installing executable from a tar.gz file on a mac. The R mac help pages I found suggest installing MacTex, which I tried but that didn't seem to help.
** Update: ** additional discussion of related problems on R-SIG-mac mailing list:
https://groups.google.com/forum/#!topic/r-sig-mac/xjyuFdl5Ezk
Update:
Here is where I'm currently at:
I removed my /sw directory to uninstall fink and all of its packages (couldn't figure out how to upgrade it)
installed homebrew
brew install texinfo installs version 5.2 the package,
but generates the message This formula is keg-only, which means it was not symlinked into /usr/local and actually installs in in /usr/local/Cellar/texinfo/5.2/bin which means it is not on the path and R won't find it.
manually symlink each of the texi2pdf, texi2dvi , etc as vincent suggests (this is because R has the /usr/local/bin location as default in the tools::texi2dvi function?
edited the /etc/paths file on the system to add /usr/local/bin so that finds the brew installed 5.2 version before it finds it before the osx system supplied version 4.6 version. This may not be necessary because R has it hardcoded?
All of this gets rid of the "can't find texi* errors", and gives me a bunch of latex errors (which I don't see on unix and windows builds) so I'm still kind of stuck.
This seems very hackish, so there must be a cleaner way? But it sounds like stuff with tex and mac is very sketchy at the moment? https://tex.stackexchange.com/questions/208181/why-did-my-tex-related-gui-program-stop-working-in-mac-os-x-yosemite
This worked for me on Mavericks and on Yosemite:
ln -s /usr/bin/texi2dvi /usr/local/bin/texi2dvi
ln -s /usr/bin/texi2pdf /usr/local/bin/texi2pdf
On my Lion system both the command which texi2pdf at a Terminal/bash prompt and from a R.app GUI prompt tell me that I have that program in:
system("which texi2pdf")
#/opt/local/bin/texi2pdf
That is a location typical for MacPorts installation. I think the /usr/local/bin/ is what the binary R version "expects". I'm not really that UNIX savvy, but I think the you can modify the PATH environment variable so that R will be able to find your installation. (Whether it will be compatible I cannot say since so much detail is missing from your question.) My Tex installation is MacTex, which I got from https://www.tug.org/mactex/. I admit to having a cobbled-together system:
system("echo $PATH")
# /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin
That gets set at the beginning of an R session because this is the first line in my .Rprofile-(invisible)file:
Sys.setenv(PATH="/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin")
I think /sw/bin/ installations signify a fink install, which I have had very little success with. Simon Urbanek suggests not using any package installers, but then leaves the rest of us UNIX weenies very little in the way of worked examples of how to install that various external packages that underpin the many interesting and oh-so-useful R packages. So I feel your pain, but I'm not running for President.
So I suppose you could try this at your R console before again attempting one of the earlier unsuccessful installs:
Sys.setenv(PATH=paste( Sys.getenv()$PATH, # should be the character string of the $PATH
"/sw/bin/", sep=":")
)
Wish I could offer guarantees, but if it breaks the only guarantee is that you get to keep all the pieces.
I ran into a similar error message using Mavericks 10.9.5 (factory configured) and R 3.1.
It turns out that I didn't have pdfLaTex. I went to this page: http://tug.org/mactex/ and downloaded the MacTex installation package. It's big (>2GB) but after I installed it, my R package build problems went away.
Hope this might be helpful to anyone else who runs into this error message.

Error installing and running rcpp

I'm pretty new to R so apologies for a stupid question. I'm trying to get rcpp running but I'm stuck in an endless loop of R asking me to re-install RTools.
I broadly followed the code in this blog post, although first time off I installed everything by hand & I've subsequently re-installed everything a few times over. I'm running Windows 7, R version 3.1.2, R Studio Version 0.98.1091 (not that this should matter much) and RTools 3.1.
An edited highlight of what my console looks like is as follows:
> library(installr)
Welcome to installr version 0.15.3...
> install.Rtools()
Loading required package: devtools
No need to install Rtools - You've got the relevant version of Rtools installed
> find_rtools()
[1] TRUE
> library(Rcpp)
> evalCpp("1+1")
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 65535 occurred building shared library.
At which point a dialog box pops up saying:
Install Build Tools
Compiling C/C++ code for R requires installation of additional build tools.
Do you want to install the additional tools now?
And then I get directed to download and re-install RTools 3.1 from cran all over again.
I've seen that this can be an issue with the PATH variable but I've tried various things including:
Nothing (extra) in the PATH variable
Including both references to R (C:\Program Files\R\R-3.1.2\bin\x64) and RTools (C:\RBuildTools\3.1\bin;C:\RBuildTools\3.1\gcc-4.6.3\bin;) in the PATH. Once with RTools first, once with R first
Including just a reference to RTools in the PATH as the initial install file directed me to do.
Any ideas on things to try would be gratefully accepted!
EDIT
Following Dirk's comment it looks like I might have a problem with how RTools is installed. I've followed the instructions from several blogs / tutorials on how to install RTools; all to no avail (yet!)
This GitHub page gives some instructions on how install and check that the installation has worked. I've followed all the checks (see below for copy of the console) and it looks like I have a working install of RTools, but when I try to run evalCPP() again I get the same error as before directing me to install RTools.
> Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R-3.1.2\\bin\\x64;C:\\RTools\\bin;C:\\RTools\\gcc-4.6.3\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Enterprise Vault\\EVClient\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\VSShell\\Common7\\IDE\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\PrivateAssemblies\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files\\Microsoft\\Web Platform Installer\\;C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\;C:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn\\"
Warning message:
printing of extremely long output is truncated
> system('g++ -v')
Using built-in specs.
COLLECT_GCC=C:\RTools\GCC-46~1.3\bin\G__~1.EXE
COLLECT_LTO_WRAPPER=c:/rtools/gcc-46~1.3/bin/../libexec/gcc/i686-w64-mingw32/4.6.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /data/gannet/ripley/Sources/mingw-test3/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --prefix=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --with-gmp=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpfr=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpc=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --disable-shared --enable-static --enable-targets=all --enable-languages=c,c++,fortran --enable-libgomp --enable-sjlj-exceptions --enable-fully-dynamic-string --disable-nls --disable-werror --enable-checking=release --disable-win32-registry --disable-rpath --disable-werror CFLAGS='-O2 -mtune=core2 -fomit-frame-pointer' LDFLAGS=
Thread model: win32
gcc version 4.6.3 20111208 (prerelease) (GCC)
> system('where make')
C:\Rtools\bin\make.exe
I've also had a look at Appendix D of R Installation and Admin. I can't see anything in here I've not already tried except for section D.4 which implies I might need to rebuild rcpp from source using my installed RTools. I don't have time to do this right away but will give it a try unless people say this route is not worth my time.
EDIT v2
So I tried building rcpp from source ... and that didn't work either. I downloaded both the package source and windows binaries from the CRAN Rcpp package page. In the R console I now get:
> install.packages(pkgs = "C:/Rcpp_0.11.4.tar.gz", repos = NULL, contriburl = NULL, type = "source", verbose = TRUE)
Installing package into ‘C:/Users/james.macadie/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
system (cmd0): C:/PROGRA~1/R/R-31~1.2/bin/x64/R CMD INSTALL
Warning in install.packages :
package ‘C:/Rcpp_0.11.4.tar.gz’ is not available (for R version 3.1.2)
I guess my active questions now boil down to:
Reading the whole of the post above can anyone tell me how to fix things so it just works? Or, failing that...
What tests can I run to check I really do have Rtools installed correctly? Everything I have found on the internet suggests I do: system('where make') etc. However, the evidence of being unable to run evalCpp or other rccp functions suggests I don't.
What am I doing wrong when building from source? Should I try the command line option?
EDIT v3
Running evalCpp with showOutput= TRUE and verbose = TRUE I think I've tracked the error back to R CMD SHLIB not working. I followed this blog, which shows how to work with the command line R directly. However when I get to the line R CMD SHLIB sequence_examples.c the execution just skips straight to the next command line without doing anything, generating any files in the directory or throwing any errors. I tried running the --help options at the command line but get the same sort of error:
C:\Users\james.macadie> R --help
Or: R CMD command args
where 'command' is one of:
INSTALL Install add-on packages
REMOVE Remove add-on packages
SHLIB Make a DLL for use with dynload
BATCH Run R in batch mode
build Build add-on packages
check Check add-on packages
Rprof Post process R profiling files
Rdconv Convert Rd format to various other formats
Rdiff difference R output files
Rd2pdf Convert Rd format to PDF
Rd2txt Convert Rd format to pretty text
Stangle Extract S/R code from vignette
Sweave Process vignette documentation
config Obtain configuration information about R
open Open a file via Windows file associations
texify Process a latex file
Use
R CMD command --help
for usage information for each command.
C:\Users\james.macadie> R CMD SHLIB --help
C:\Users\james.macadie>
N.B. for people reading the earlier code samples higher up this post I have changed a few things since those code snapshots:
I've installed R directly into C:\R. It used to be in C:\Program Files\R\ but as has been suggested file paths with spaces in can cause problems
I'm referencing Rtools under C:\Rtools\ and not C:\RBuildTools\
Thanks for any suggestions, as ever
Had the same endless loop issue when trying to install Twitter's BreakoutDetection (which is also written in cpp)
fixed by executing the following
Sys.setenv(PATH="%PATH%;C:/Rtools/gcc-4.6.3/bin;c:/Rtools/bin")
and then answering "no" when presented with the following prompt:
"Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. Do you want to install the additional tools now?"
Didn't try these actions independently so not sure if either on their own would have fixed the issue
I found that ensuring all of these were in my path fixed it. I did this with RStudio closed; I didn't reboot after.
C:\Program Files\R\R-3.1.3\bin\x64
C:\Program Files\R\R-3.1.3\bin
C:\RBuildTools\3.2\bin
C:\RBuildTools\3.2\gcc-4.6.3\bin64
C:\RBuildTools\3.2\gcc-4.6.3\bin
C:\RBuildTools\3.2\gcc-4.6.3\i686-w64-mingw32\bin
These are on my Win7-64bit computer. YMMV, and I'm mostly posting this to ensure others see it if they are having the same issue.
In the end it was something a bit left-field. Inspired by the following post, I had a look at the ComSpec environment variable. Not quite sure how, but I had it set to "cmd.exe".
Removing the double quotes, so it said cmd.exe, and then rebooting fixed everything.
Thanks to all who've tried to help.
I experienced the same problem, I fixed this problem by adding Rtools dir into env variables:
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")

Resources