闪亮的服务器发生错误加载命名空间没有包 rcpp 但 rcpp 已安装并在 R 中加载闪亮工作

shiny server an error has occured load namespace no package rcpp but rcpp is installed and loading shiny in R works

我最近试图在我的服务器上打开一个闪亮的服务器应用程序,但遇到了这个我以前从未见过的错误。

   Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck     = vI[[j]]) : 
      there is no package called ‘Rcpp’
    Error: package or namespace load failed for ‘shiny’
    Execution halted

我假设某个更新损坏了某些东西。然而,当在我的机器上启动 R 时,library(shiny)library(Rcpp) 加载都没有任何问题。

所以我尝试重新安装 shiny-server。根据他们的指示here,但是我基本上得到与上面相同的错误:

sudo su - \
> -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""

R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages('shiny', repos='http://cran.rstudio.com/')
Installing package into â/usr/local/lib/R/site-libraryâ
(as âlibâ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/shiny_0.12.1.tar.gz'
Content type 'application/x-gzip' length 1473559 bytes (1.4 MB)
==================================================
downloaded 1.4 MB

* installing *source* package âshinyâ ...
** package âshinyâ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
  there is no package called âRcppâ
ERROR: lazy loading failed for package âshinyâ
* removing â/usr/local/lib/R/site-library/shinyâ
* restoring previous â/usr/local/lib/R/site-library/shinyâ

The downloaded source packages are in
        â/tmp/RtmpUfc19u/downloaded_packagesâ
Warning message:
In install.packages("shiny", repos = "http://cran.rstudio.com/") :
  installation of package âshinyâ had non-zero exit status

我不知道这是为什么,因为 shiny 和 Rcpp 在刚启动 R 时甚至在以 sudo 启动 R 时都安装和加载完美。

我的 sessionInfo() 输出是:

R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu precise (12.04.5 LTS)

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=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] shiny_0.12.1 Rcpp_0.11.6

loaded via a namespace (and not attached):
[1] R6_2.0.1        htmltools_0.2.6 digest_0.6.8    xtable_1.7-4
[5] httpuv_1.3.2    mime_0.3

在此先感谢您的指点或帮助。

显然,这是一个 library/permissions 问题。我对 R 包管理和所有可能的不同库位置(当然是在使用 Rstudio 服务器和 shiny 服务器和 bioconductor 等)以及何时或不使用 sudo 来安装包仍然有点模糊。任何好的指导方针都可能会避免这个问题。

Rstudio (sudo su -\ -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\"") 人员建议的代码让我思考:当我 运行 只是终端中的 R 或 sudo R library(Rcpp)library(shiny) 工作,所以我只是 sudo su 然后 运行 R 与 install.packages('shiny', repos='http://cran.rstudio.com/') 交互。这表明显然对于 root 用户 (su) 没有安装 Rcpp 包 (!)。手动安装软件包后,我还可以重新安装 shiny,我的 shiny 应用程序又开始工作了。

我仍然担心的是 如何 Rcpp 包 "dissappeared" 首先来自根 R 包。我不记得自己删除了它,如果更新会导致这种情况,我会发现它是相当不愉快的行为。

无论哪种方式:问题已解决。也许这个答案可以帮助其他有类似问题的人。