yihui/servr

rmd fails to compile when running servr::jekyll() - Windows10 - live updating doesn't work

melindahiggins2000 opened this issue · 7 comments

I cloned the https://github.com/yihui/knitr-jekyll site. From there, I tried editing one of the RMD files for the blog post while running servr::jekyll() to watch it update in real time. When I do, I get the following error:

> servr::jekyll()
<simpleError: Failed to compile _source/2014-09-28-jekyll-with-knitr.Rmd>

* Retrying in 2 seconds...

After hitting STOP, I then get the next error message:

Warning message:
running command '"C:/PROGRA~1/R/R-33~1.0/bin/x64/Rscript" "build.R" "_source/2014-09-28-jekyll-with-knitr.Rmd" "_posts/2014-09-28-jekyll-with-knitr.md"' had status 1 

However, if I run system("jekyll b) to build the site and then run servr::jekyll() the files have been created and I can see the updates from RMD blog file. But I cannot seem to get this to work in real time.

Note: When running jekyll from a "Administrator Start Command Prompt with Ruby" (i.e. the Windows command window), I can run jekyll s, open a browser window at http://127.0.0.1:4000/knitr-jekyll// and then when I edit the MD files, I see real time updates to the website after refreshing the browser.

My sessionInfo() is:

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

loaded via a namespace (and not attached):
[1] rsconnect_0.4.2.2 tools_3.3.0       Rcpp_0.12.5      
[4] knitr_1.13        httpuv_1.3.3      mime_0.4         
[7] servr_0.4        
> 

I'm sure this is a Windows specific issue - perhaps something having to do with path assignments. I am running the following version of Ruby, jekyll and these gems:

C:\MyR\knitr-jekyll>ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]

C:\MyR\knitr-jekyll>gem list

*** LOCAL GEMS ***

bigdecimal (1.2.6)
colorator (0.1)
ffi (1.9.10 x64-mingw32)
io-console (0.4.3)
jekyll (3.1.6)
jekyll-sass-converter (1.4.0)
jekyll-watch (1.4.0)
json (1.8.1)
kramdown (1.11.1)
liquid (3.0.6)
listen (3.0.8)
mercenary (0.3.6)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
rdoc (4.2.0)
rouge (1.11.1)
safe_yaml (1.0.4)
sass (3.4.22)
test-unit (3.0.8)
wdm (0.1.1)

I also have a Gemfile located in this directory which references the wdm gem.

Directory contents:

C:\MyR\knitr-jekyll>dir
 Volume in drive C has no label.
 Volume Serial Number is AC7D-A6A5

 Directory of C:\MyR\knitr-jekyll

06/23/2016  09:17 AM    <DIR>          .
06/23/2016  09:17 AM    <DIR>          ..
06/18/2016  07:59 PM                49 .gitignore
06/21/2016  07:49 PM             1,570 .Rhistory
06/21/2016  09:26 AM    <DIR>          .sass-cache
06/18/2016  07:59 PM               470 about.md
06/18/2016  07:59 PM             1,308 build.R
06/21/2016  09:26 AM    <DIR>          css
06/18/2016  07:59 PM             1,292 feed.xml
06/21/2016  09:28 AM    <DIR>          figure
06/23/2016  09:13 AM                44 Gemfile
06/18/2016  07:59 PM               506 index.html
06/18/2016  07:59 PM               300 knitr-jekyll.Rproj
06/18/2016  07:59 PM             1,077 LICENSE
06/18/2016  07:59 PM               979 README.md
06/21/2016  11:40 AM               625 _config.yml
06/21/2016  09:26 AM    <DIR>          _includes
06/21/2016  09:26 AM    <DIR>          _layouts
06/21/2016  09:26 AM    <DIR>          _posts
06/21/2016  09:26 AM    <DIR>          _sass
06/23/2016  09:19 AM    <DIR>          _site
06/21/2016  09:26 AM    <DIR>          _source
              11 File(s)          8,220 bytes
              11 Dir(s)  88,548,069,376 bytes free

Gemfile

gem 'wdm', '>= 0.1.0' if Gem.win_platform?

This edit is suggested at the Ruby documentation for listen, see http://www.rubydoc.info/gems/listen#On_Windows.

Thank you for your help. I'm hoping someone else may have run into this issue with Windows and maybe knows a workaround.

I really like the servr package even without the live updating feature working on Windows.

PS. I'm running the RStudio preview version 0.99.1220

yihui commented

I cannot tell what the problem is from your description. You can execute this in R and see what the exact error message is:

system2("C:/PROGRA~1/R/R-33~1.0/bin/x64/Rscript", c("build.R", "_source/2014-09-28-jekyll-with-knitr.Rmd", "_posts/2014-09-28-jekyll-with-knitr.md"))

Thank you for your suggestion. Here are my results:

> system2("C:/PROGRA~1/R/R-33~1.0/bin/x64/Rscript", c("build.R", "_source/2014-09-28-jekyll-with-knitr.Rmd", "_posts/2014-09-28-jekyll-with-knitr.md"))
Quitting from lines 60-60 (_source/2014-09-28-jekyll-with-knitr.Rmd) 
Error in eval(expr, envir, enclos) : object 'jekyll' not found
Calls: local ... capture.output -> evalVis -> withVisible -> eval -> eval
Execution halted
Warning message:
running command '"C:/PROGRA~1/R/R-33~1.0/bin/x64/Rscript" build.R _source/2014-09-28-jekyll-with-knitr.Rmd _posts/2014-09-28-jekyll-with-knitr.md' had status 1 

I found the offending lines in the 2014-09-28-jekyll-with-knitr.Rmd file - at row 60-61, the r code chunk

{r code=formatR::usage(jekyll), eval=FALSE}

throws an error stating that it cannot find the jekyll object. I tried installing and loading the formatR package and running it again. In the console typing the command formatR::usage(jekyll) runs fine, but for some reason here in the code chunk it causes a compilation error.

Is there something I need to do to get the code=formatR::usage(jekyll) r chunk option to work?

If I remove (comment out) this code chunk, everything works perfectly.

Thank you for your time and feedback.

Also if I move the code into the chunk block instead of in the header, the rmd file compiles and the jekyll live update works fine. So, here is my edit


```{r eval=FALSE}
formatR::usage(jekyll)```

the above code chunk works fine, but this one with the code in the r chunk header does not

```{r code=formatR::usage(jekyll), eval=FALSE}```

Maybe I need an update to the knitr package or perhaps be using the development version?

yihui commented

Thanks for providing the error message. I just fixed the Rmd source document in the knitr-jekyll repo. Instead of formatR::usage(jekyll), I should have used formatR::usage(servr::jekyll).

Great. Glad to help. Thank you again for the quick response. Wonderful package!