truncating string with embedded nuls in Notebook

I am taking my first tentative steps with R-Notebooks and whatever I do, I get dozens of warnings:

In readChar(file, size, TRUE) : truncating string with embedded nuls

Initially I thought it was coming from source-ing a script, but now it seems to happen with almost any code block. I am not using readChar explicitly anywhere.

I also wondered if there was an incompatibility in the encoding of script files, but haven't been able to find a suitable setting to stop it (currently ISO8859-1), but frankly I am just guessing blindly.

Any idea what causes this and how I can stop them?

I am using R version 4.0.0 (2020-04-24) -- "Arbor Day"

2 Likes

It is possible that this only happens when Chunk Output Inline is set.
Too early to say for sure, but it has never shown these warnings when sending to the console.

I am curious if anyone else has experience of this.

Just wanna chime in and say that I've experienced the same issue after updating to R version 4.0.0. Using any other version of R solves the issue.

I get the error message you mention every time I try and use the kable() function to create an HTML table from a code chunk. The warnings disappear if i change the chunk option so that only the output is shown (echo = FALSE). In addition, the errors causes my R session to freeze, possibly due to high CPU usage.

Note that I cannot reproduce the problem outside my notebook but I'll try and see if I can make a reprex tomorrow.

I am guessing that this issue might be due to an incompatibility between the new R version and the knitr package?

A reproducible example would be helpful.

Indeed it would, but for me it is every notebook with inline output.

This example did it for me

Notebooks

but I doubt it would for many others.

It is probably more to do with RStudio configuration.
I am guessing that regional settings in Windows plays a role, but really I have no idea.

1 Like

Just checked the results for the template notebook and I can reproduce the problem there. If I create the notebook, hit the preview button and then run the code chunk I get 26 instances of the error message:

In readChar(file, size, TRUE) : truncating string with embedded nuls

So I can only reproduce the problem after previewing the notebook by running the code chunk. Note that the errors appear when I knit to PDF or any other format.

System Information:

RStudio Edition: Desktop
RStudio Version: 1.2.5042
OS Version: Windows 10 x64 (build 18363)
R Version: 4.0.0
1 Like

Is there a way of at least suppressing the message that there are warnings in the viewer output?

Then I could just ignore it.

When I have chunk_output_type set to inline, it shows in the viewer

There were 50 or more warnings (use warnings() to see the first 50)

The chunk options include echo=FALSE, message=FALSE, warning=FALSE, error=FALSE, but it still messes up the output. If it isn't one of those, what is it?

I started having the same issue just after updating to R 4.0.0.
No idea why, and it's a bit annoying.

I can recreate this too. For me it seems to require at least two chunks, one of which produces some output like a figure. Run all chunks then preview, and then running the first chunk produces this repeated set of warnings inline or in console that is variable in length each time.

---
title: "R Notebook"
output: html_notebook
---


```{r}
a <- 1
```
```{r}
plot(cars)
```

platform x86_64-apple-darwin17.0
arch x86_64
os darwin17.0
system x86_64, darwin17.0
status
major 4
minor 0.0
year 2020
month 04
day 24
svn rev 78286
language R
version.string R version 4.0.0 (2020-04-24)
nickname Arbor Day

Rstudio Version 1.2.5042

OS X v 10.15.4

Do you also experience Rstudio crashing/freexing in larger notebooks or Rmarkdown documents? I have problems with this but can't recreate the problem in a simple example.

Thanks! I've now reproduced this and have filed a bug report here:

It looks like the issue reproduces whenever one attempts to save an R Notebook which contains inline image outputs.

5 Likes

Should this be fixed with the latest version of RStudio, 1.3.959? I can still reproduce this error.

It looks like it has been fixed in v1.3.1019-1 Preview. See the Release Note.

1 Like

Seems similar to an issue when using kableExtra::kable_styling()

that is not resolved with RStudio version: 1.3.1019, which contains this fix.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.