【问题标题】:Error deploying shiny app with command line使用命令行部署闪亮的应用程序时出错
【发布时间】:2017-02-19 11:35:40
【问题描述】:

我目前正在尝试使用 Windows 机器上的计划任务部署闪亮的应用程序。这个想法是,每天早上运行一个脚本并从多个位置聚合数据,然后将其放入一些 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() 时设置存储库有关。我希望这与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

【问题讨论】:

  • 看看这是否有帮助 stackoverflow.com/questions/17705133/… 当您的代码中有 library(something) 时,如果未安装,deployApp 函数将需要在服务器上安装这些软件包,这就是 @987654341 @进来了。
  • 据我从rsconnect 的文档中得知,它会查找闪亮应用程序所需的libraries,并将其安装在shinyapps.io 上。我可能遗漏了一些东西,但我原以为服务器负责设置 repo。
  • 我确实更新了 .rprofile 文件以包含默认的 CRAN 镜像,并且它部署良好。
  • 如果您手动将应用部署到 shinyapps.io,而不使用 taskscheduleR,会发生什么
  • 从 RStudio 中部署可以正常工作(从部署按钮,或使用控制台中的命令)。

标签: r shiny


【解决方案1】:

设置

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

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

【讨论】:

  • 我将该行添加到我的应用程序的deploy.R 脚本中,现在它运行良好。
猜你喜欢
  • 2016-02-24
  • 2020-08-07
  • 2017-09-22
  • 1970-01-01
  • 1970-01-01
  • 2018-05-24
  • 2018-09-24
  • 2021-04-30
相关资源
最近更新 更多