在具有空间的路径中调用可执行文件时出现问题

Roc*_*nce 5 r path environment-variables command-line-interface

我刚刚在新的Microsoft Windows 7计算机上安装了R,并且在使用命令行时出现以下错误:

"C:\Program Files\R\R-3.3.2\bin\Rscript.exe" --version  
'C:\Program' is not recognized as an internal or external command,
Run Code Online (Sandbox Code Playgroud)

可操作程序或批处理文件.

请注意,我在路径周围添加了带空格的引号.我在系统路径中添加了:

;C:\Program Files\R\R-3.3.2\bin\

有趣的是:

  1. 如果我只是调用Rscript.exe --version它它会给出相同的错误,这是非常奇怪的:如果它找到它,为什么它不能运行它!?!我能找到的唯一解释是在查找Rscript.exe的依赖项时发生错误
  2. 我还注意到,这工作"C:\Program Files\R\R-3.3.3\bin\x64\Rscript.exe" --version(这两个文件夹...\bin,并...\bin\x64具有可执行Rscript.exe)

最后我确认这是一个R特定问题,因为我在Program Files子文件夹中尝试的所有其他可执行文件都可以通过相同的命令行界面调用!

Dav*_*man 0

查看

C:\Users>Rscript --help
Usage: /path/to/Rscript [--options] [-e expr [-e expr2 ...] | file] [args]

--options accepted are
  --help              Print usage and exit
  --version           Print version and exit
  --verbose           Print information on progress
  --default-packages=list
                      Where 'list' is a comma-separated set
                        of package names, or 'NULL'
or options to R, in addition to --slave --no-restore, such as
  --save              Do save workspace at the end of the session
  --no-environ        Don't read the site and user environment files
  --no-site-file      Don't read the site-wide Rprofile
  --no-init-file      Don't read the user R profile
  --restore           Do restore previously saved objects at startup
  --vanilla           Combine --no-save, --no-restore, --no-site-file
                        --no-init-file and --no-environ

'file' may contain spaces but not shell metacharacters
Expressions (one or more '-e <expr>') may be used *instead* of 'file'
See also  ?Rscript  from within R
Run Code Online (Sandbox Code Playgroud)

根据您的理论,即某些依赖性有问题,我希望 --verbose 能够指示 Rscript 尝试读取的其他文件。没有这样的运气。

顺便说一句,除非我也向 Rscript 提供一些命令,否则这些选项几乎对我来说都不可用——否则它会一直抱怨“文件名丢失”。因此,对于这些可能性中的任何一种,您都可以选择类似的东西

C:\Users>Rscript --verbose -e print(2+2)
Run Code Online (Sandbox Code Playgroud)

--no-environ话虽这么说,您可以通过使用、--no-site-file、等选项来进一步追求您的理论--vanilla,使其跳过任何文件依赖项,看看它是否能让您到达某个地方。