r - 使用命令行部署 Shiny 的应用程序时出错

标签 r shiny

我目前正尝试在 Windows 机器上使用计划任务部署 Shiny 的应用程序。这个想法是每天早上运行一个脚本,从多个位置聚合数据,然后将其放入一些 R data.table 对象中,以供 shiny应用程序。

我正在使用 taskscheduleR安排任务。它最初将工作目录设置为 C:/Windows/system32,因此我将其修复为指向我的应用程序所在的目录 (C:/rprojects/myappname)。在我尝试部署文件之前,脚本运行良好。

library(rsconnect)
deployApp(appName = "myappname", upload = TRUE, appFileManifest = "manifest.txt",account = "myaccountname", server = "shinyapps.io")

当我从 taskscheduleR 检查日志时,我有以下几行

Preparing to deploy application...DONE
Uploading bundle for application: 999999...Error in contrib.url(getOption("repos"), type) : 
  trying to use CRAN without setting a mirror
Calls: deployApp ... withCallingHandlers -> <Anonymous> -> available.packages -> contrib.url
Execution halted

我已经搜索了错误消息,我能找到的所有内容都与使用 install.packages() 时设置 repo 有关,我没有在我的脚本中使用它。我希望它与 deployApp 尝试查找 URL 的方式有关,但是我可以理解我可能需要(或能够)声明存储库的位置。

更新 (2016-10-11): 我已经为 rsconnect 激活了几个选项以获取有关部署的更多详细信息。不幸的是,它无助于提供任何更大的清晰度。

options(rsconnect.http.trace = TRUE)
options(rsconnect.http.trace.json = TRUE)
options(rsconnect.http.verbose = TRUE)

下面是log

的输出
    GET /v1/applications/?filter=account_id:999999&filter=name:myappname&count=100&offset=0 1500ms
* Hostname was NOT found in DNS cache
*   Trying 54.225.182.222...
*   Trying 174.129.219.111...
* Connected to api.shinyapps.io (54.225.182.222) port 443 (#0)
  * successfully set certificate verify locations:
    *   CAfile: C:/RLibrary/rsconnect/cert/cacert.pem
  CApath: none
  * SSL connection using TLSv1.0 / ECDHE-RSA-AES128-SHA
  * Server certificate:
    *    subject: OU=Domain Control Validated; CN=*.shinyapps.io
  *      start date: 2016-07-18 14:17:38 GMT
  *      expire date: 2017-09-09 23:05:10 GMT
  *      subjectAltName: api.shinyapps.io matched
  *      issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
  *      SSL certificate verify ok.
  > GET /v1/applications/?filter=account_id:999999&filter=name:myappname&count=100&offset=0 HTTP/1.1
  User-Agent: rsconnect/0.4.3
  Host: api.shinyapps.io
  Accept: */*
    Date: Tue, 11 Oct 2016 01:26:02 GMT
  X-Auth-Token: xxxxxx
  X-Auth-Signature: xxxxxx; version=1
  X-Content-Checksum: xxxxxx

  < HTTP/1.1 200 OK
  < Content-Type: application/json; charset=UTF-8
  < Date: Tue, 11 Oct 2016 01:23:36 GMT
  < Etag: "xxxxxx"
  < Server: nginx/1.4.2
  < Content-Length: 3212
  < Connection: keep-alive
  < 
    * Connection #0 to host api.shinyapps.io left intact
  Error in contrib.url(getOption("repos"), type) : 
    trying to use CRAN without setting a mirror
  Calls: deployApp ... withCallingHandlers -> <Anonymous> -> available.packages -> contrib.url
  Execution halted

最佳答案

设置

options(repos = c(CRAN = "https://cran.rstudio.com/")) 

在你想用 taskscheduleR 启动的脚本顶部的某个地方 如果您使用 Rscript 启动 R,则不会设置 CRAN 存储库,这与您在 RStudio 编辑器中运行代码不同。

关于r - 使用命令行部署 Shiny 的应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39968575/

相关文章:

r - 如何在 valueBox shinydashboard 中格式化货币值?

r - 将 Hive 表从 HDFS 移动到 Amazon Redshift

r - 在SF对象上设置正确的crs以绘制坐标点

r - 基于重复逻辑向量元素粘贴字符串

Shiny 的响应式(Reactive) DateRangeInput

r - Redshift 上 Shiny 缓慢

r - 当我在 group_by() 和 summarize() 链中使用自己的函数时,它错误地为每个组返回相同的结果

r - 如何在R中按顺序重新编号组ID?

r - 如何使用共享数据库将多个 Shiny 应用程序集成到一个网站中?

r - 如何在 Shiny 中使用可编辑的 DataTable 作为另一个 DataTable 的输入