r - 如何在闪亮的应用程序中使用 renv 包以避免在闪亮的服务器上安装新包?
问题描述
我想测试renv
闪亮的应用程序包。这是我的虚拟应用程序:
library(pool)
library(fresh)
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui = ui, server = server)
请注意,我只加载了 2 个库pool
而不fresh
使用它们。
init()
包中的命令renv
正在我的项目路径上创建一个本地库:
renv::init("/home/z0044uca/mytest_renv/")
* Initializing project ...
* Discovering package dependencies ... Done!
* Copying packages into the cache ... [21/21] Done!
The following package(s) will be updated in the lockfile:
# CRAN ===============================
- BH [* -> 1.72.0-3]
- R6 [* -> 2.4.1]
- Rcpp [* -> 1.0.5]
- base64enc [* -> 0.1-3]
- commonmark [* -> 1.7]
- crayon [* -> 1.3.4]
- digest [* -> 0.6.25]
- fastmap [* -> 1.0.1]
- glue [* -> 1.4.2]
- htmltools [* -> 0.5.0]
- httpuv [* -> 1.5.4]
- jsonlite [* -> 1.7.1]
- later [* -> 1.1.0.1]
- magrittr [* -> 1.5]
- mime [* -> 0.9]
- promises [* -> 1.1.1]
- renv [* -> 0.12.5]
- rlang [* -> 0.4.7]
- shiny [* -> 1.5.0]
- sourcetools [* -> 0.1.7]
- withr [* -> 2.2.0]
- xtable [* -> 1.8-4]
* Lockfile written to '~/mytest_renv/renv.lock'.
* Project '~/mytest_renv' loaded. [renv 0.12.5]
Restarting R session...
* Project '~/mytest_renv' loaded. [renv 0.12.5]
我的问题是如何将应用程序部署到我的闪亮服务器而不在服务器上安装两个包(pool
和fresh
)。
当我将整个文件夹 ( mytest_renv
) 复制到我的服务器并尝试在浏览器中运行应用程序时,我收到以下错误(在log
文件中)
Warning message:
The following package(s) are missing entries in the cache:
base64enc, BH, commonmark, crayon, DBI, digest, fastmap,
fresh, fs, glue, htmltools, httpuv, jsonlite, later,
magrittr, mime, pool, promises, R6, rappdirs, Rcpp, rlang,
rstudioapi, sass, shiny, sourcetools, withr, xtable
These packages will need to be reinstalled.
Error in loadNamespace(name) : there is no package called ‘digest’
Calls: local ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
我期待renv
我的应用程序目录中的文件夹负责所有包和依赖项。
解决方案
https://community.rstudio.com/t/shiny-server-renv/71879/2可能是相关的——你可能想renv::isolate()
在复制你的项目文件夹之前打电话。
推荐阅读
- python - 使用熊猫库读取后尝试将 csv 列数据拆分为列表
- android - 如何从 Places AutoComplete Fragment 的结果返回中获取相应的 LatLon
- java - 带有 Weblogic 12c 的 Eclipse 不会在断点处停止
- c# - 将实现接口的泛型类型类分配给作为接口的泛型类型
- visual-c++ - 对于 64 位目标,在 MSVC 2019 中找不到 MMX 内在函数,例如 _mm_cvtpd_pi32;从 2013 年开始变化?
- buffer - pyUSB - 延迟发送到设备?
- angular - 响应式表单提交状态
- javascript - 无法在 C# 中使用 Selenium WebDriver 执行 JavaScript 命令
- python - 为列表中的每个数据框添加一列时出现问题
- c++ - 初始化一个动态分配的数组