Reputation: 679
I'm exploring package building on Windows 7 but have been running into trouble after reaching the Command Prompt stage. The following thread appears to be on the same topic that I'm having trouble with, but the question remains unresolved:
The problem: whenever I try an R CMD command in Command Prompt (e.g. I've tried R CMD install pkgName
, R cmd install pkgName
, Rcmd install pkgName
, where pkgName
is a place-holder for an actual package that has been R CMD check
ed on OS X and also posted on CRAN, where I have the unzipped source in the current working directory), I get the following error message:
'R' is not recognized as an internal or external command,
operable program or batch file.
(If I try the Rcmd install pkgName
command, then the error starts out as 'Rcmd' is not ...
.) Note that even if I type in just R
in Command Prompt and hit enter, I get the same error, so I'm not even able to bring up R here, though it opens perfectly fine in its stand-alone interface.
I have examined the following guides without success in identifying the trouble:
The most immediate thing that came to mind was that the path variables in Windows were not set right, but this also has not (yet) led to the answer. For example, I have triple-checked the paths to ensure they are correct, including for the R version number, that x64
in the path name is accurate, etc.
I realize this is a complex issue to remotely diagnose, but any advice and suggestions on resolving this trouble is appreciated. For reference, below are the steps I have taken already to try to resolve this issue:
I updated the path variables on my computer, where the below paths were used:
C:\Rtools\bin; C:\Program Files\R\R-2.15.0\bin\x64;
I've also tried the R CMD
(and Rcmd
) commands with the following paths included (note that these paths don't lead to anything on my computer, so I tried doing R CMD
/ Rcmd
with and without them specified):
C:\Rtools\perl\bin; C:\Rtools\MinGW\bin;
Tried adding/removing the following path, which goes to the only other folder visible within the Rtools folder:
C:\Rtools\gcc-4.6.3;
Tried multiple variations of the R CMD
commands, as noted earlier.
Note: I already had Cygwin installed prior to R and Rtools, and I have not installed MikTeX (yet).
Upvotes: 32
Views: 60308
Reputation: 479
In my case the issue was solved by using Edit instead of New while selecting PATH in the window below:
After selecting Edit I added the directory below:
C:\Program Files\R\R-4.0.2\bin\x64
This solved the issue in my case.
Upvotes: 0
Reputation: 1
In the .bat file add a line of code specifying the path of the folder where R is installed and then give the path of the script as follows -
@ECHO OFF
PATH C:\Program Files\R\R-3.5.1\bin
R CMD BATCH D:\project_abc\helloworld.R
Following this, run the .bat file and you will see the code in the script will run smoothly.
Upvotes: 0
Reputation: 1696
I encountered a similar problem while trying to use SparkR from Windows Power Shell. Each time I would do ".\sparkR.cmd" (I was inside the folder containing this file), it would throw an error message like,
cmd is not recognized as an internal and external command...blah...blah...blah.
I solved the problem by adding "C:\Windows\System32" to my PATH.
I restarted my system and then repeated the process and this time, I saw a new error,
R is not recognized as an internal and external command...blah...blah...blah.
I tried all sorts of approaches, including the ones mentioned above. NOTHING WORKED, I was probably wasn't efficient enough to make it work.
Then I came across this place at code.google. I simply copied the R.bat onto a notepad, named it as R.bat. Kept it inside the folder where sparkR.cmd was located. For me it was,
C:\Apache\spark-1.5.1-bin-hadoop2.6\bin\
The I placed it on my PATH as :
C:\Apache\spark-1.5.1-bin-hadoop2.6\bin\R.bat
Restarted my laptop, opened my Power Shell as an administrator and typed :
.\R.bat help
It worked fine. Then I typed,
.\sparkR.cmd
and there it was.
It worked.
I hope it helps to people new to R. Thank you G. Grothendieck.
Upvotes: 3
Reputation: 61
Simple solution, use quotes:
c:> "C:\Program Files\WinZip\wzunzip.exe"
if you run this, you don't need to worry about the space in Program Files.
Hope this help.
Upvotes: 3
Reputation: 81
I had a lot of trouble getting this to work, and finally found the golden nugget on r-project (R doesn't like spaces in paths) so here's how I finally did all this:
Upvotes: 6
Reputation: 2912
It appears that the CMD processor is Case Sensitive. You have to use INSTALL vs. install
Upvotes: 3
Reputation: 61
I attach my whole solution here:
PATH: C:\Program Files\R\R-2.15.1\bin\x64;C:\Rtools\bin;C:\Rtools\gcc-4.6.3\bin
R CMD INSTALL packagename
Click "enter", done.
Upvotes: 6
Reputation: 17517
PATH
on the command line and ensure that you are properly updating your pathcd C:\Program...\bin\x64
, R.exe
./bin;C:/Program...
. Try combining that with Joshua's solution.Upvotes: 21