R4.1.0 and [rsession-rstudio] System ERROR 13 & 84 (Invalid or incomplete multibyte or wide character)

After upgrading to R 4.1.0 and RStudio 1.4.1717 from R 4.0.5 & Rstudio 1.4.1106 (custom docker container, based on rocker/tidyverse),
I started seeing these messages printed in Red, to Rstudio console.

16 Jun 2021 01:16:27 [rsession-rstudio] ERROR system error 84 (Invalid or incomplete multibyte or wide character) [str: はここでmcparallelジョブを, len: 34, from: UTF-8, to: ISO8859-1]; OCCURRED AT rstudio::core::Error rstudio::r::util::{anonymous}::iconvstrImpl(const string&, const string&, const string&, bool, std::__cxx11::string*) src/cpp/r/RUtil.cpp:187; LOGGED FROM: rstudio::core::Error rstudio::session::modules::spelling::{anonymous}::checkSpelling(const rstudio::core::json::JsonRpcRequest&, rstudio::core::json::JsonRpcResponse*) src/cpp/session/modules/SessionSpelling.cpp:225
16 Jun 2021 01:16:27 [rsession-rstudio] ERROR system error 84 (Invalid or incomplete multibyte or wide character) [str: して, len: 6, from: UTF-8, to: ISO8859-1]; OCCURRED AT rstudio::core::Error rstudio::r::util::{anonymous}::iconvstrImpl(const string&, const string&, const string&, bool, std::__cxx11::string*) src/cpp/r/RUtil.cpp:187; LOGGED FROM: rstudio::core::Error rstudio::session::modules::spelling::{anonymous}::checkSpelling(const rstudio::core::json::JsonRpcRequest&, rstudio::core::json::JsonRpcResponse*) src/cpp/session/modules/SessionSpelling.cpp:225
16 Jun 2021 01:16:27 [rsession-rstudio] ERROR system error 84 (Invalid or incomplete multibyte or wide character) [str: ざっくり, len: 12, from: UTF-8, to: ISO8859-1]; OCCURRED AT rstudio::core::Error rstudio::r::util::{anonymous}::iconvstrImpl(const string&, const string&, const string&, bool, std::__cxx11::string*) src/cpp/r/RUtil.cpp:187; LOGGED FROM: rstudio::core::Error rstudio::session::modules::spelling::{anonymous}::checkSpelling(const rstudio::core::json::JsonRpcRequest&, rstudio::core::json::JsonRpcResponse*) src/cpp/session/modules/SessionSpelling.cpp:225

It seems "comments" in the R files opened in RStudio editor are somehow leaking? causing such errors.
Comments written with Japanese characters cause the error, ASCII only comments seem unaffected by this.
Script execution is not interrupted, it is a cosmetic issue. (but a little unnerving. may cause further errors down the line.)

I have several machines with source files synced via github.
This error is reproducible, by using the same image based on latest R 4.1.0 image.
If I roll back to 4.0.5 image, the problem disappears.
Exact symptom on 4 of my machines running Ubunto 18.04 & 20.04 so I expect this to be an issue with the image than my local setup.

Is anyone experiencing the same issue?
Any advices where should I look into, to correct the errors?

Thanks! Taiyo

2 Likes

I'm answering my own question, since I was guided to a solution!

tldr; "Disable realtime spell checking"

The error was triggered in the following sequence:
Container startup : no error
Opening a project : no error
Open any R script: Errors in console

upon closer inspection, it began with one error 13, followed by multiple error 84.

23 Jun 2021 04:48:07 [rsession-rstudio] ERROR system error 13 (Permission denied) [path: /home/rstudio/.config/rstudio/dictionaries/custom, target-dir: ]; OCCURRED AT rstudio::core::Error rstudio::core::FilePath::createDirectory(const string&) const src/cpp/shared_core/FilePath.cpp:812; LOGGED FROM: std::vector<std::__cxx11::basic_string<char> > rstudio::core::spelling::HunspellCustomDictionaries::dictionaries() const src/cpp/core/spelling/HunspellCustomDictionaries.cpp:35
23 Jun 2021 04:48:07 [rsession-rstudio] ERROR system error 84 (Invalid or incomplete multibyte or wide character) [str: ワルキューレ, len: 18, from: UTF-8, to: ISO8859-1]; OCCURRED AT rstudio::core::Error rstudio::r::util::{anonymous}::iconvstrImpl(const string&, const string&, const string&, bool, std::__cxx11::string*) src/cpp/r/RUtil.cpp:187; LOGGED FROM: rstudio::core::Error rstudio::session::modules::spelling::{anonymous}::checkSpelling(const rstudio::core::json::JsonRpcRequest&, rstudio::core::json::JsonRpcResponse*) src/cpp/session/modules/SessionSpelling.cpp:225
...

I am only guessing here, but perhaps Japanese characters (many of which overlap with Chinese characters in UTF-8 spec, but they are two different language set. 'CJK unified ideographs' in Unicode spec is a monster of a ruleset to implement... ) are misidentified as Chinese language, causing errors?

Also, "install more languages" drop-down menu in RStudio options seems broken, at least from 4.0.5.
Hope I could enable the feature sometime in future!

Disabling realtime spell check cleared the problem for now.

2 Likes

just a quick note, you can disable the realtime spellchecking, by adding this entry to ~/.config/rstudio/rstudio-prefs.json

"real_time_spellchecking": false
1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.