我一直在尝试解决 VS Code 中的一个问题,即 R 语言服务器无法加载,并产生以下错误消息:
R Language Server (8931) started
Error: package or namespace load failed for ‘tidyverse’:
.onAttach failed in attachNamespace() for 'tidyverse', details:
call: NULL
error: package or namespace load failed for ‘stringr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/lib/R/library/stringi/libs/stringi.so':
libicui18n.so.73: cannot open shared object file: No such file or directory
Execution halted
R Language Server (8931) exited with exit code 1
以下答案表明问题可能出在
stringi
软件包上。长话短说,我最终删除了 stringi
软件包,并尝试重新安装它,导致出现与上面类似的错误消息:
$> install.packages("stringi")
Error: package or namespace load failed for ‘tidyverse’:
.onAttach failed in attachNamespace() for 'tidyverse', details:
call: NULL
error: package or namespace load failed for ‘stringr’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘stringi’
Execution halted
The downloaded source packages are in
‘/tmp/Rtmpu5V2g7/downloaded_packages’
Warning message:
In install.packages("stringi") :
installation of package ‘stringi’ had non-zero exit status
我可以使用一些帮助来理解错误消息以及如何解决问题。
我尝试安装不同的软件包:
install.packages("fortunes"
这会返回与上面类似的错误,缺少
stringi
。
然后我尝试删除
tidyverse
和 stringr
,然后再次安装 tidyverse
,这返回了以下错误消息:
> remove.packages("tidyverse")
> remove.packages("stringr")
> install.packages("tidyverse")
Error in library(tidyverse) : there is no package called ‘tidyverse’
Execution halted
来自此 answer 的信息表明问题在于 R 尝试加载
stringi
,然后在未正确安装时加载 tidyverse
。
使用
--vanilla
标志从终端运行 R,然后安装 tidyverse
解决了问题:
$> sudo R --vanilla
> install.packages("tidyverse")