Skip to content

Commit bebf17c

Browse files
BUG FIX: Shiny apps running as background jobs in RStudio [#183]
1 parent 497592a commit bebf17c

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: progressr
2-
Version: 0.16.0-9002
2+
Version: 0.16.0-9003
33
Title: An Inclusive, Unifying API for Progress Updates
44
Description: A minimal, unifying API for scripts and packages to report progress updates from anywhere including when using parallel processing. The package is designed such that the developer can to focus on what progress should be reported on without having to worry about how to present it. The end user has full control of how, where, and when to render these progress updates, e.g. in the terminal using utils::txtProgressBar(), cli::cli_progress_bar(), in a graphical user interface using utils::winProgressBar(), tcltk::tkProgressBar() or shiny::withProgress(), via the speakers using beepr::beep(), or on a file system via the size of a file. Anyone can add additional, customized, progression handlers. The 'progressr' package uses R's condition framework for signaling progress updated. Because of this, progress can be reported from almost anywhere in R, e.g. from classical for and while loops, from map-reduce API:s like the lapply() family of functions, 'purrr', 'plyr', and 'foreach'. It will also work with parallel processing via the 'future' framework, e.g. future.apply::future_lapply(), furrr::future_map(), and 'foreach' with 'doFuture'. The package is compatible with Shiny applications.
55
Authors@R: c(person("Henrik", "Bengtsson",

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Version (development version)
22

3-
* ...
3+
## Bug Fixes
44

5+
* Shiny apps running as background jobs in RStudio could fail with an
6+
error "object 'RStudio.Version' of mode 'function' was not found".
7+
This error occurred sporadically.
8+
59

610
# Version 0.16.0 [2025-05-18]
711

R/options.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,8 @@ update_package_options <- function(debug = FALSE) {
263263

264264
## However, not used
265265
update_package_option("global.handler", mode = "logical", debug = debug)
266+
267+
## For RStudio users
268+
update_package_option("rstudio.patch", mode = "logical", debug = debug)
266269
}
270+

R/rstudio-console.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ get_rstudio_version <- local({
22
.version <- NULL
33
function() {
44
if (is.null(.version)) {
5-
if (!"tools:rstudio" %in% search()) {
6-
.version <<- package_version("0.0")
7-
} else {
5+
.version <<- package_version("0.0")
6+
if ("tools:rstudio" %in% search()) {
87
envir <- as.environment("tools:rstudio")
9-
RStudio.Version <- get("RStudio.Version", mode = "function", envir = envir, inherits = FALSE)
10-
.version <<- RStudio.Version()[["version"]]
8+
## There are cases where 'tools:rstudio' exist, but there is no
9+
## RStudio.Version() function. See
10+
## https://github.com/futureverse/progressr/issues/183 for
11+
## an example. Not sure how that happens. /HB 2025-09-23
12+
if (exists("RStudio.Version", mode = "function", envir = envir, inherits = FALSE)) {
13+
RStudio.Version <- get("RStudio.Version", mode = "function", envir = envir, inherits = FALSE)
14+
.version <<- RStudio.Version()[["version"]]
15+
}
1116
}
1217
}
1318
.version

0 commit comments

Comments
 (0)