• R语言
  • blogdown 建立网站出现错误

问题说明

之前的标题有误,我的问题是 RStudio 无法knitr rmarkdown,错误如下:

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Execution halted

我的系统环境

sessionInfo()

R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_3.5.2 bookdown_0.9 htmltools_0.3.6 tools_3.5.2

[5] yaml_2.2.0 Rcpp_1.0.0 rmarkdown_1.11 blogdown_0.10

[9] knitr_1.22 xfun_0.5 digest_0.6.18 evaluate_0.13

    已安装的包

    Package Version
    askpass 1.1
    assertthat 0.2.0
    backports 1.1.3
    base64enc 0.1-3
    BH 1.69.0-1
    bitops 1.0-6
    blogdown 0.10
    bookdown 0.9
    broom 0.5.1
    callr 3.1.1
    caTools 1.17.1.2
    cellranger 1.1.0
    cli 1.0.1
    clipr 0.5.0
    colorspace 1.4-0
    crayon 1.3.4
    curl 3.3
    DBI 1.0.0
    dbplyr 1.3.0
    digest 0.6.18
    dplyr 0.8.0.1
    ellipsis 0.1.0
    evaluate 0.13
    fansi 0.4.0
    forcats 0.4.0
    fs 1.2.6
    generics 0.0.2
    ggplot2 3.1.0
    glue 1.3.0
    gtable 0.2.0
    haven 2.1.0
    highr 0.7
    hms 0.4.2
    htmltools 0.3.6
    httpuv 1.4.5.1
    httr 1.4.0
    jsonlite 1.6
    knitr 1.22
    labeling 0.3
    later 0.8.0
    lazyeval 0.2.1
    lubridate 1.7.4
    magrittr 1.5
    markdown 0.9
    mime 0.6
    miniUI 0.1.1.1
    modelr 0.1.4
    munsell 0.5.0
    openssl 1.2.2
    pillar 1.3.1
    pkgconfig 2.0.2
    plogr 0.2.0
    plyr 1.8.4
    prettyunits 1.0.2
    processx 3.3.0
    progress 1.2.0
    promises 1.0.1
    ps 1.3.0
    purrr 0.3.1
    R6 2.4.0
    RColorBrewer 1.1-2
    Rcpp 1.0.0
    readr 1.3.1
    readxl 1.3.0
    rematch 1.0.1
    reprex 0.2.1
    reshape2 1.4.3
    rlang 0.3.1
    rmarkdown 1.11
    rprojroot 1.3-2
    rstudioapi 0.9.0
    rvest 0.3.2
    scales 1.0.0
    selectr 0.4-1
    servr 0.13
    shiny 1.2.0
    sourcetools 0.1.7
    stringi 1.3.1
    stringr 1.4.0
    sys 3.1
    tibble 2.0.1
    tidyr 0.8.3
    tidyselect 0.2.5
    tidyverse 1.2.1
    tinytex 0.10
    utf8 1.1.4
    viridisLite 0.3.0
    whisker 0.3-2
    withr 2.1.2
    xfun 0.5
    xml2 1.2.0
    xtable 1.8-3
    yaml 2.2.0

    删掉那个有问题的rmd能不能行
    另外路径里有没有中文

      albert-R 你的问题跟那些人报告的问题都不一样(错误消息不同)。麻烦你用纯命令行试试:

      d = tempfile()
      dir.create(d)
      blogdown::new_site(d)
      traceback()

        试了下命令行yihui
        d = tempfile()
        dir.create(d)
        blogdown::new_site(d)

        trying URL 'https://github.com/yihui/hugo-lithium/archive/master.zip'
        downloaded 117 KB

        processing 7 content files
        Rendering content/post/2015-07-23-r-rmarkdown.Rmd
        Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
        Execution halted
        Error in render_page(f) :
        Failed to render 'content/post/2015-07-23-r-rmarkdown.Rmd'

        结果是一样的。

        tctcab 删除 rmd 后就可以了,Viewer 里出现了网站,谢谢。
        blogdown:::serve_site()

        Building sites …
        | EN

        +------------------+----+
        Pages | 11

        Paginator pages | 0

        Non-page files | 0

        Static files | 11

        Processed images | 0

        Aliases | 0

        Sitemaps | 1

        Cleaned | 0

        Total in 24 ms

        Update: 之前的问题描述有误,系 RStudio 无法 knitr rmarkdown. 误导大家了,不好意思。

          albert-R

          锁定到这个文件的话应该容易排查错误了,你试试直接knit一下这个RMD文档看会不会报错。

            tctcab 会。错误信息和之前一样

            Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
            Execution halted

            不好意思我问错问题了。这不是 blogdown 的锅,我的 RStudio 现在只要是打开 Rmd 文件就会报错。我好像不能修改问题标题,麻烦版主帮忙改成 RStudio 无法 knitr Rmd.

              tctcab 谢谢指出,我已经按截图里的方式设置了。

              请问怎么删除 .Rdata?我在 working directory 里找不到这个文件,只会直接 rm(list = ls()). 我其实没懂那个链接的意思,因为每次我用 R 新开project 都会选一个 directory,应该影响不大?

              补充:谢谢您的回答。我的 Windows PC还能正常工作,先就这样凑合着用用。说不定过几天 mac 就好了...

                albert-R 是不是保存到 HOME 文件夹里了?

                dir('~')
                if(file.exists('~/.Rdata')) file.remove('~/.Rdata')

                  dapengde 这番操作后,运行默认的 rmarkdown 模板还是有问题。错误信息和之前一样

                  Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
                  Execution halted

                  dir('~')

                  [1] "Applications" "Desktop"

                  [3] "Documents" "Downloads"

                  [5] "Dropbox" "hw"

                  [7] "Library" "Movies"

                  [9] "Music" "OneDrive - HKUST Connect"
                  [11] "Pictures" "Public"

                  [13] "temp" "thesis"

                  [15] "VirtualBox VMs"

                  if(file.exists('~/.Rdata')) file.remove('~/.Rdata')

                  [1] TRUE

                    dapengde 这个error 打开 R Console 就存在。

                    R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
                    Copyright (C) 2018 The R Foundation for Statistical Computing
                    Platform: x86_64-apple-darwin15.6.0 (64-bit)

                    R is free software and comes with ABSOLUTELY NO WARRANTY.
                    You are welcome to redistribute it under certain conditions.
                    Type 'license()' or 'licence()' for distribution details.

                    Natural language support but running in an English locale

                    R is a collaborative project with many contributors.
                    Type 'contributors()' for more information and
                    'citation()' on how to cite R or R packages in publications.

                    Type 'demo()' for some demos, 'help()' for on-line help, or
                    'help.start()' for an HTML browser interface to help.
                    Type 'q()' to quit R.

                    Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
                    [R.app GUI 1.70 (7612) x86_64-apple-darwin15.6.0]

                    [History restored from /Users/lhr45678/.Rapp.history]

                    我在 applications 里删除然后重新安装 R,错误依然存在。我测试了下,现在 R 可以定义函数,调用哥哥包画图等,但一旦 knitr Rmarkdown 这个错误就会出现。

                    albert-R 光是 dir() 不够,要看有没有隐藏文件,尤其是有没有 .Rprofile(如果有,则打开看看):

                    list.files('~', all.files = TRUE)

                    从你 file.remove('~/.Rdata') 返回 TRUE 来看,你好像有在退出 R 时保存工作空间的恶习;如上面 tctcab 所说,我也强烈建议不要保存。

                      yihui 感谢!存在 .Rprofile, 我把它删除后,现在可以 knitr 其他 .Rmd 文件了。用 blogdown build 网站也没问题🎉

                      我有两个疑惑,可以麻烦其他版友空闲时间解答一下么?表达可能不太清晰,我尽力。

                      1. 关于“退出 R 保存工作空间的恶习”。感谢 @tctcab 提供的图片教程。我以为 knitr 会在新的 working session 里编译 .Rmd 文件,但现在当前的工作空间里的 .Rprofile 也影响了 .Rmd 的编译?

                      2. 关于.Rprofile文件。我应该附上.Rprofile文件,但我在删除 (file.remove('~/.Rprofile')) 它前没有保存... 现在垃圾箱里找不到它,试着在终端里打开也没有...

                        AlbertdeMacBook-Air:~ lhr45678$ cd ~/.Trash
                        AlbertdeMacBook-Air:.Trash lhr45678$ ls -a
                        .		..		.DS_Store

                      我删除 .Rprofile 前打开瞅了几眼。根据回忆,我应该是按照益辉的书 1.4 Global options 部分设置的,

                      options(blogdown.ext = ".Rmd", blogdown.author = "Albert")
                      # in .Rprofile of the website project
                      if (file.exists("~/.Rprofile")) {
                        base::sys.source("~/.Rprofile", envir = environment())
                      }
                      # then set options(blogdown.author = 'Albert') in
                      # ~/.Rprofile

                        albert-R

                        看这段代码,我猜是这段代码在根目录的.Rprofile里,导致启动后无限递归地source这个~/.Rprofile文件…

                        重点是这句

                        in .Rprofile of the website project