首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >installr:install.pandoc()似乎已损坏

installr:install.pandoc()似乎已损坏
EN

Stack Overflow用户
提问于 2018-12-15 08:06:40
回答 1查看 272关注 0票数 0

我最近注意到installr包中的install.pandoc函数似乎被破坏了。

我得到以下错误消息:

代码语言:javascript
复制
trying URL 'https://github.com/'    
Content type 'text/html; charset=utf-8' length unknown    
downloaded 78 KB

github.com is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.

看起来该函数没有从GitHub中找到合适的文件。我已经向GitHub上的installr包提交了一个拉取请求,它纠正了这个错误。

EN

回答 1

Stack Overflow用户

发布于 2018-12-15 08:07:45

下面是应该正确安装Pandoc的函数,该函数是作为拉取请求提交的。以防您在修复之前遇到此错误。

代码语言:javascript
复制
library(installr)
FixedInstall.Pandoc <- function (URL = "https://github.com/jgm/pandoc/releases", use_regex = TRUE, 
          to_restart, ...) 
{
  URL <- "https://github.com/jgm/pandoc/releases"
  page_with_download_url <- URL
  if (!use_regex) 
    warning("use_regex is no longer supported, you can stop using it from now on...")
  page <- readLines(page_with_download_url, warn = FALSE)
  sysArch <- Sys.getenv("R_ARCH") 
  sysArch <-  gsub("/ |/x", "", sysArch)
  pat <- paste0("jgm/pandoc/releases/download/[0-9.]+/pandoc-[0-9.-]+-windows",".*", sysArch, ".*", ".msi")
  target_line <- grep("windows", page, value = TRUE)
  m <- regexpr(pat, target_line)
  URL <- regmatches(target_line, m)
  URL <- head(URL, 1)
  URL <- paste("https://github.com/", URL, sep = "")
  installed <- install.URL(URL, ...)
  if (!installed) 
    return(invisible(FALSE))
  if (missing(to_restart)) {
    if (is.windows()) {
      you_should_restart <- "You should restart your computer\n in order for pandoc to work properly"
      winDialog(type = "ok", message = you_should_restart)
      choices <- c("Yes", "No")
      question <- "Do you want to restart your computer now?"
      the_answer <- menu(choices, graphics = "TRUE", title = question)
      to_restart <- the_answer == 1L
    }
    else {
      to_restart <- FALSE
    }
  }
  if (to_restart) 
    os.restart()
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53788391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档