I'm sorry for the cross-posting; at the beginning I didn't realize it was a RStudio specific problem, but then I noticed that plain R doesn't suffer from it, so I created an issue in github problem because it looked like a bug to me.
In github they noticed from a RStudio diagnostic report that I provided that in the locale setting there was an impossible locale:
$LANG  "en_IT.UTF-8" $LC_CTYPE  "en_IT.UTF-8"
en_IT doesn't make sense because it would mean an italian version of english. In fact those options are not present in my machine locales (fetched by
locale -a on terminal).
The problem is confirmed running
LANG en_IT.UTF-8 LC_CTYPE en_IT.UTF-8
I don't really know where these setting come from.
The workaround to make everything work is using
Sys.setlocale(locale = 'en_US.UTF-8'). But I think it's a problem of RStudio interacting with Mojave.
Thanks to @phahn who gave me a useful hint.