question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kniting to html_document and Knitting to html preview freeze at 0%

See original GitHub issue

Describe 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.

Screenshot 2022-12-15 065628

Screenshot 2022-12-15 072201

To Reproduce

  1. Install VS Code
  2. Install Docker Desktop - if on Windows (as I am and my colleague) then this will require WSL2 installation and configuration
  3. Create directory for files
  4. Create Dockerfile; provided below
  5. Create .devcontainer/devcontainer.json; provided below
  6. Create dependencies.R; provided below
  7. Create explore Rmd.Rmd; provided below
  8. Open VS code session in directory with files: code <path to directory with files>
  9. Ensure Docker Desktop is running
  10. Rebuild container without cache (takes ~20 minutes to build on my machine)
  11. Navigate to explore Rmd.Rmd within the Dev Container
  12. Run the code chunks and observe output to the radian console
  13. 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%
  14. 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:closed
  • Created 9 months ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
KatlehoJordancommented, Dec 15, 2022

I will try, thank you.

0reactions
KatlehoJordancommented, Dec 17, 2022

Update:

Even with the linked rocker container, the RMarkdown knitting to html 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found