You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VSCode中使用全局站点库安装R包?

在VSCode的R扩展v5.2.3中安装R包到全局站点库的权限问题

我在使用VSCode的R扩展v5.2.3安装R包时遇到权限问题:VSCode尝试写入的目录/usr/local/lib/R/site-library无写入权限。该目录是我以root身份启动R并从控制台安装包时使用的全局站点库,我希望将R包安装在此处。

以普通用户身份启动VSCode安装R包here时,出现如下错误:

Executing task: /usr/bin/R --silent --slave -e install.packages(c('here'),repos='https://cloud.r-project.org/') 

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages(c("here"), repos = "https://cloud.r-project.org/") :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Error in install.packages(c("here"), repos = "https://cloud.r-project.org/") : 
  unable to install packages
Execution halted

*  The terminal process "/usr/bin/R '--silent', '--slave', '-e', 'install.packages(c('here'),repos='https://cloud.r-project.org/')'" failed to launch (exit code: 1). 
*  Terminal will be reused by tasks, press any key to close it. 

请问是否可以通过VSCode使用全局库/usr/local/lib/R/site-library管理我的R包?

我的Linux系统信息:

~$ uname -rvmpo
5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 GNU/Linux

R环境信息:

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20.3

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=sv_SE.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=sv_SE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base      

loaded via a namespace (and not attached):
[1] compiler_4.2.1

内容的提问来源于stack exchange,提问作者habana

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 02:05:26