我目前正试图在Windows计算机上使用计划任务部署闪亮的应用。这个想法是,脚本每天早上运行并汇总来自多个位置的数据,然后将其放入一些R
data.table
对象中,以用于shiny
应用程序。使用命令行部署闪亮的应用时出错
我正在使用taskscheduleR
来安排任务。它最初将工作目录设置为C:/Windows/system32
,因此我将其修复为指向我的应用程序所在的目录(C:/rprojects/myappname
)。脚本运行良好,直到我尝试部署文件。
当我从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
看看这是否有用http://stackoverflow.com/questions/17705133/package-error-when-running-r-code-on-command-line当你在代码中有'library(something)'时, 'deployApp'函数将需要在服务器上安装软件包,如果它们没有安装,那就是'install.packages'进来的地方。 –
据我可以从'rsconnect'的文档中看出来,它会查找'库“,这是闪亮的应用程序所必需的,并将其安装在'shinyapps.io'上。我可能会错过一些东西,但我会认为服务器负责设置回购。 – Dan
我更新了'.rprofile'文件以包含默认的'CRAN'镜像,并且它部署正常。 – Dan