我目前正在尝试使用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
答案 0 :(得分:3)
set
options(repos = c(CRAN = "https://cran.rstudio.com/"))
somewhere at the top of your script which you wanted to launch with taskscheduleR If you launch R with Rscript, the CRAN repository is not set, which is different then if you run your code in the RStudio editor.