简体   繁体   English

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

[英]installr:install.pandoc() appears broken

I recently noticed that the install.pandoc function in the installr package appears to be broken. 我最近注意到installr程序包中的install.pandoc函数似乎已损坏。

I get the following error message: 我收到以下错误消息:

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.

It looks like the function is not finding the appropriate file from GitHub. 似乎该函数未从GitHub找到合适的文件。 I have submitted a pull request to the installr package on GitHub which corrects this error. 我已向GitHub上的installr软件包提交了一个拉取请求,可纠正此错误。

Here is the function that should install Pandoc correctly and that was submitted as a pull request. 这是应该正确安装Pandoc并作为请求请求提交的函数。 In case you run into this error before it is fixed. 如果您在修复此错误之前遇到了该错误。

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()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM