1

我正在尝试在谷歌云平台上增加我的包的版本一个 R 会话。我想我一定遗漏了一些东西,因为我认为何时which设置代码应该能够在没有进一步用户输入的情况下运行。

rlang::is_interactive()FALSE如我所料返回。

usethis::use_version(which = "minor")
✔ Setting active project to '/home/jupyter/x/y'

Error: User input required, but session is not interactive.
Query: There are uncommitted changes and you're about to bump version
Do you want to proceed anyway?
Traceback:

1. usethis::use_version("minor")
2. challenge_uncommitted_changes(msg = "There are uncommitted changes and you're about to bump version")
3. ui_yeah("{msg}\nDo you want to proceed anyway?")
4. ui_stop(c("User input required, but session is not interactive.", 
 .     "Query: {x}"))

这是功能代码:https ://github.com/r-lib/usethis/blob/master/R/version.R

function (which = NULL) 
{
    if (is.null(which) && !is_interactive()) {
        return(invisible(FALSE))
    }
    check_is_package("use_version()")
    challenge_uncommitted_changes(msg = "There are uncommitted changes and you're about to bump version")
    new_ver <- choose_version("What should the new version be?", 
        which)
    if (is.null(new_ver)) {
        return(invisible(FALSE))
    }
    use_description_field("Version", new_ver, overwrite = TRUE)
    if (names(new_ver) == "dev") {
        use_news_heading("(development version)")
    }
    else {
        use_news_heading(new_ver)
    }
    use_c_version(new_ver)
    git_ask_commit("Increment version number", untracked = TRUE, 
        paths = c("DESCRIPTION", "NEWS.md", path("src", "version.c")))
    invisible(TRUE)
}

这是choose_version() 中可能存在的错误吗?

R版

platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          6.3                         
year           2020                        
month          02                          
day            29                          
svn rev        77875                       
language       R                           
version.string R version 3.6.3 (2020-02-29)
nickname       Holding the Windsock  
4

1 回答 1

1

这个问题是由存储库中未提交的更改驱动的,这触发了use_version.

具体在 challenge_uncommitted_changes(msg = "There are uncommitted changes and you're about to bump version").

这导致返回错误消息。

我通过提交所有未跟踪/修改的文件来解决这个问题。

我已将此标记给包维护者,因为我认为有必要让函数以非交互方式运行而无需提交更改。

感谢@MrFlick关于如何解决这个问题的正确建议。

于 2021-07-20T09:34:55.130 回答