Kniting to html_document and Knitting to html preview freeze at 0%
See original GitHub issueDescribe the bug
I have built a VS Code Dev Container for a colleague to explore R in VS Code in order to convince them to replace RStudio. Within the Dev Container, when I use the commands to knit a .Rmd
file to .html
or to preview the html in another pane, an information window appears that the document is being knit, but it never advances past 0%. See the screenshots.
To Reproduce
- Install VS Code
- Install Docker Desktop - if on Windows (as I am and my colleague) then this will require WSL2 installation and configuration
- Create directory for files
- Create
Dockerfile
; provided below - Create
.devcontainer/devcontainer.json
; provided below - Create
dependencies.R
; provided below - Create
explore Rmd.Rmd
; provided below - Open VS code session in directory with files:
code <path to directory with files>
- Ensure Docker Desktop is running
- Rebuild container without cache (takes ~20 minutes to build on my machine)
- Navigate to
explore Rmd.Rmd
within the Dev Container - Run the code chunks and observe output to the radian console
- Try to knit the document from the command palette (
ctrl
/cmd
+shift
+p
-> ‘R: knit Rmd to HTML’)- Observe the popup window that it tries to knit but does not proceed past 0%
- Try to open the preview of the rendered document from the command palette (
ctrl
/cmd
+shift
+p
-> ‘R Markdown: Open Preview’)- Observe the popup window that it tries to knit but does not proceed past 0%
Can you fix this issue by yourself? (We appreciate the help)
I would like to try to help, but am unsure how to proceed, 😦
Files for reproducing
Dockerfile
FROM r-base:4.2.2
WORKDIR /usr/src
COPY . .
RUN \
apt-get update && \
apt-get install -y \
python3 \
python3-pip \
libxml2-dev \
libfontconfig1-dev \
libcurl4-openssl-dev \
libssl-dev \
pandoc \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev \
&& \
Rscript dependencies.R && \
pip3 install -U radian && \
echo "alias r=radian" >> /etc/bash.bashrc
CMD [""]
.devcontainer/devcontainer.json
{
"name": "Existing Dockerfile",
"context": "..",
"dockerFile": "../Dockerfile",
"extensions": [
"REditorSupport.r",
"ms-vscode.live-server",
],
"settings": {
"[r]": {
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.defaultFormatter": "REditorSupport.r"
},
"r.bracketedPaste": true,
"r.plot.useHttpgd": true,
"files.associations": {
"*.Rmd": "rmd"
}
}
}
dependencies.R
cores_to_use <- max(parallel::detectCores() - 2, 1)
install.packages("remotes", Ncpus = cores_to_use)
packages <- c(
"languageserver" = "0.3.14",
"tidyr" = "1.2.1",
"httpgd" = "1.3.0",
"ggplot2" = "3.4.0",
"plotly" = "4.10.1",
"shiny" = "1.7.3",
"rmarkdown" = "2.18"
)
for (pkg in names(packages)) {
remotes::install_version(pkg, packages[pkg], Ncpus = cores_to_use)
}
explore Rmd.Rmd
# Section 1
## Subsection 1.1
# Editing R Markdown
```{r}
m <- lm(mpg ~ ., data = mtcars)
summary(m)
```
```{r chunk-1}
x <- rnorm(100)
y <- rnorm(100)
```
```{r plot1}
plot(rnorm(100))
abline(h = 0, col = "red")
```
```{r plot2}
plot(rnorm(100))
abline(h = 0, col = "green")
```
Issue Analytics
- State:
- Created 9 months ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Crashing When knitting R Markdown under Linux
I am knitting my R Markdown into HTML with the following command rmarkdown::render("document. Rmd") .
Read more >Rmd - not giving erros but also no html output document
Try to render your problem . Rmd document using the Knit button. Go to the R Markdown tab (should have appeared in the...
Read more >15 Common Problems with rmarkdown (and some solutions)
Develop code in chunks and execute the chunks until they work, then move on. knit the document regularly to check for errors. Then,...
Read more >Rmd document not rendering to HTML in preview release #3965
This refuses to render to HTML when using the latest preview release (1.2.1153-1) but works just fine with the last official release (1.1.463)....
Read more >Preview button gone, can only Knit : r/RStudio - Reddit
Preview only shows up for R Notebooks (i.e. the output is html_notebook ). You probably need to change the output format in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I will try, thank you.
Update:
Even with the linked
rocker
container, the RMarkdown knitting tohtml
is not working. The same behavior is observed.I do believe that some days ago I was able to render the previews to the side and knit with the GUI provided by the extension, but since I cannot replicate there’s a chance my memory is wrong.
If my memory is correct though, then it seems I’ve changed something in my machine that has led to this problem, but I’m not sure what. Commenting out my entire
settings.json
file does not resolve the problem, so I do not think it’s a VS Code problem but rather a system-wide problem.