I installed R version 3.2.0 in my "C:\Program Files" folder, and then installed RStudio. When I tried to run an R markdown file, it prompted me to install the Rmarkdown package from source. However, I found that Installing RMarkdown packages in RStudio does not work on Windows 7.
Digging a little deeper I found that the R CMD --help command worked, but every R CMD <command> and R CMD <command> --help fails with
'C:\Program' is not recognized as an internal or external command, operable program or batch file
If I had tested my installation, I would have found the problem with
Sys.setenv(LC_COLLATE = "C", LANGUAGE = "en")
library("tools")
testInstalledBasic("both")
since that fails by calling R CMD BATCH during its execution.
The only solution I could find was to uninstall R and reinstall it a "C:" instead of "C:\Program Files."
It seems like installing R into the "Program Files" folder should be possible. Is there some configuration that would make that possible? Or is there some reason this basic scenario isn't supported?
Related
I ran into this today. I installed R 3.4.3 along side R 3.4.1 . Using LyX/knitr under R 3.4.1 everything was fine. After adding R 3.4.3, changing the System/User/LyX PATH entries from 3.4.1 to 3.4.3, LyX launches Rscript, but it can no longer open the Rnw file in the TEMP folder. LyX freaks out and pops up an error message. My work around was to copy Rscript from R 3.4.1 and everything works again.
Did the command line parameters change from R-3.4.1 toR-3.4.3 ?
Everything seems fine for Rstudio and report compilation. Do the LyX Rscript command line parameters need to be changed for R-3.4.3 ? This occurred under Windows 10 on a X64 laptop and i386 tablet. It's consistent anyway!
Is there a fix for R-3.4.3 or LyX 2.2.3 ?
Updated info:
The LyX console reports the following:
18:10:32.825: Rscript --verbose --no-save --no-restore "C:/Users/dave/AppData/Local/LyX 2.2/Resources/scripts/lyxknitr.R" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.Rnw" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.tex" ISO-8859-15 "C:/Users/dave/LaTeX Work/Lyx Work/"
18:10:33.241: The filename, directory name, or volume label syntax is incorrect.
support/Systemcall.cpp (291): Systemcall: 'Rscript --verbose --no-save --no-restore "C:/Users/dave/AppData/Local/LyX 2.2/Resources/scripts/lyxknitr.R" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.Rnw" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.tex" ISO-8859-15 "C:/Users/dave/LaTeX Work/Lyx Work/"' finished with exit code 1
Error: Cannot convert file
----------------------------------------
An error occurred while running:
Rscript --verbose --no-save --no-restore $$s/scripts/lyxknitr.R
"C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-kn…
18:10:41.526: Error while exporting format: PDF (pdflatex)
The tempfile exists and I can read it in Notepad++. Note that LyX works fine, R-3.4.3 works fine, but the LyX->Knitr->R->LaTeX-> PDF chain is broken in Rscript. For every installed R upgrade, I've changed the System/User/LyX PATH variables and everything has been fine with knitr until now. My next step is to completely uninstall LyX and R-3.4.3 and reinstall. I'm a little hesitant to proceed with that if I have a simple configuration change/error that may appear again in future upgrades to LyX (2.3) and R (3.4.3+).
I think the problem is that there are two different bin directories for R, one for x64, and one for i386.
So make sure LyX is configured to use the i386 path if you are on a 32 bit machine, e.g.
C:\R\bin\i386\
I am trying to script the installation of R 2.15.1 on Windows 7. R installs just fine, but I cannot figure out how to install multiple packages from the same batch script (or any batch script, for that matter). Below is the part of the script where I call a simple R file.
"%ProgramFiles%\R\R-2.15.1\bin\R.exe" CMD BATCH "%~dp0R packages for GME.R"
Here is the contents of "R packages for GME.R" that has the packages to install.
install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
Given documented ownership and ACLs issues with writing to the default library folder in Windows, I've tried the following:
Taking ownership of "C:\Program Files\R\R-2.15.1\library", then running R CMD BATCH <file> (no change);
Giving "Full Control" permissions to my user account on the same folder, then running R CMD BATCH <file> (no change);
Changing the library folder to another location via Rprofile.site, then running R CMD BATCH <file> (no change);
Running command via Rgui install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE) (works).
So far, I have had no luck using CMD or batch scripts to install packages. Is there something I'm missing? Any alternative ways of scripting package installation would be greatly appreciated.
Also, the machines I will be installing on are for multiple users, so system-wide installations and configurations are preferred.
//
Edit 2012-11-06:
Here is the error message from the .Rout file:
install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
Warning in install.packages("CircStats", "coda", "deldir", "gplots", "igraph", :
'lib = "coda"' is not writable
Error in install.packages("CircStats", "coda", "deldir", "gplots", "igraph", :
unable to install packages
Execution halted
If I execute library(coda) afterwards, it gives Error in library(coda) : there is no package called ‘coda’.
The odesolve package is depreciated and has been replaced by deSolve. R 2.15.1 is throwing an error when encountering this package. It could be causing problems for you. Here's a script I use for installing packages for new R installs.
libs=c("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields")
type=getOption("pkgType")
CheckInstallPackage <- function(packages, repos="http://cran.r-project.org",
depend=c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances"), ...) {
installed=as.data.frame(installed.packages())
for(p in packages) {
if(is.na(charmatch(p, installed[,1]))) {
install.packages(p, repos=repos, dependencies=depend, ...)
}
}
}
CheckInstallPackage(packages=libs)
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/")
I've been having trouble downloading the shinyapps package on my windows computer. I've updated my versions of R and studio, tried the devtools download devtools::install_github('rstudio/shinyapps') and I've also tried the manual download of the shinyapps-master.zip (github.com/rstudio/shinyapps/archive/master.zip) and using install_local() all to no avail.
Here is the error I get with each method:
Installing shinyapps
"C:/Program Files/R/R-3.1.1/bin/i386/R" --vanilla CMD INSTALL \
"C:\Users\MyName\AppData\Local\Temp\Rtmpma2fl1\devtools10cc1745fe7\shinyapps-master" \
--library="C:/Program Files/R/R-3.1.1/library" --install-tests
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed (1)
After doing the excellent tutorial for shiny I would love to be able to use shinyapps.io but can't so far due to this. Any ideas? Much appreciated!
The app does not like the fact that R is installed in a directory that includes a space. I recommend reinstalling R to a location without a space, e.g. c:/R/.
I got a similar problem. I deleted the shinyapp folder first and then the file with that name. All my packages are saved in ~/Documents/R/win-library/3.1 folder on Windows 7 PC as I have not specified the lib folder. Then I installed the shinyapps package again using devtools::install_github('rstudio/shinyapps') command in R. HTH
I am trying to script the installation of R 2.15.1 on Windows 7. R installs just fine, but I cannot figure out how to install multiple packages from the same batch script (or any batch script, for that matter). Below is the part of the script where I call a simple R file.
"%ProgramFiles%\R\R-2.15.1\bin\R.exe" CMD BATCH "%~dp0R packages for GME.R"
Here is the contents of "R packages for GME.R" that has the packages to install.
install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
Given documented ownership and ACLs issues with writing to the default library folder in Windows, I've tried the following:
Taking ownership of "C:\Program Files\R\R-2.15.1\library", then running R CMD BATCH <file> (no change);
Giving "Full Control" permissions to my user account on the same folder, then running R CMD BATCH <file> (no change);
Changing the library folder to another location via Rprofile.site, then running R CMD BATCH <file> (no change);
Running command via Rgui install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE) (works).
So far, I have had no luck using CMD or batch scripts to install packages. Is there something I'm missing? Any alternative ways of scripting package installation would be greatly appreciated.
Also, the machines I will be installing on are for multiple users, so system-wide installations and configurations are preferred.
//
Edit 2012-11-06:
Here is the error message from the .Rout file:
install.packages("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields",dep=TRUE)
Warning in install.packages("CircStats", "coda", "deldir", "gplots", "igraph", :
'lib = "coda"' is not writable
Error in install.packages("CircStats", "coda", "deldir", "gplots", "igraph", :
unable to install packages
Execution halted
If I execute library(coda) afterwards, it gives Error in library(coda) : there is no package called ‘coda’.
The odesolve package is depreciated and has been replaced by deSolve. R 2.15.1 is throwing an error when encountering this package. It could be causing problems for you. Here's a script I use for installing packages for new R installs.
libs=c("CircStats","coda","deldir","gplots","igraph","ks","odesolve","RandomFields")
type=getOption("pkgType")
CheckInstallPackage <- function(packages, repos="http://cran.r-project.org",
depend=c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances"), ...) {
installed=as.data.frame(installed.packages())
for(p in packages) {
if(is.na(charmatch(p, installed[,1]))) {
install.packages(p, repos=repos, dependencies=depend, ...)
}
}
}
CheckInstallPackage(packages=libs)