我在Mac osx 10.11.6(El Capitan)上运行R 3.6.0,并在通过system()调用Rscript时收到“致命错误:为'-e'创建临时文件失败”错误。
test_cmd <- "/Library/Frameworks/R.framework/Resources/bin/Rscript -e 'print(\"Hello\")'"
system(test_cmd, intern = TRUE)
返回此错误:
[1] "Fatal error: creating temporary file for '-e' failed"
attr(,"status")
[1] 2
Warning message:
In system(test_cmd, intern = TRUE) :
running command '/Library/Frameworks/R.framework/Resources/bin/Rscript -e 'print("Hello")'' had status 2
当尝试通过将来建立集群时,出现此错误,这导致我出现了此特定示例。
future::makeClusterPSOCK(1, outfile = NULL, verbose = TRUE)
这也会调用Rscript并失败,并显示相同的错误。
此外,如果我从命令行调用Rscript,它将运行良好。
我整理出来-大约一年前,我在.REnviron文件中设置了TMPDIR变量,同时尝试修复其他我猜想的问题。该文件夹无效,仅在运行系统调用时使用。将R升级到3.6.1并不能解决该问题,因为该文件一直在那里。
解决方案:删除.REnviron中的违规行