2

I'm trying to increase the version of my package an R session on google cloud platform. I think I must be missing something because I thought when which was set that the code should be able to run without further user input.

rlang::is_interactive() returns FALSE as I'd expect.

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

Here's the function code: 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)
}

Is this a possible bug in choose_version()?

R Version

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  
JCran
  • 375
  • 2
  • 14
  • The problem seems to be you have uncommitted changes in your repo. It's that message that's trying to show you a prompt to get feedback on how to proceed. Have you not committed your most recent changes? Check your git status. – MrFlick Jul 19 '21 at 19:37
  • @MrFlick Thanks, yeah that is rather staring me in the face coming back to it. There are changes in the repo I don't want to commit, which I'll probably have to add to the .gitignore. I'll maybe raise an issue on the repo asking if they want to include an option to work aroudn this. I'll test this tomorrow and add it as an answer. – JCran Jul 19 '21 at 20:59

1 Answers1

2

This problem was driven by uncommitted changes in the repository, this triggered interactive behaviour in use_version.

Specifically in challenge_uncommitted_changes(msg = "There are uncommitted changes and you're about to bump version").

This caused the error message to be returned.

I fixed this by committing all untracked/modified files.

I've flagged this to the package maintainers, as I think there's a case to be made to let the function run non-interactively without having to commit changes.

Thanks @MrFlick for his correct suggestion on how to fix this.

JCran
  • 375
  • 2
  • 14