Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

devtools::dev_sitrep() fails after the change in RStudio version numbering #2397

Closed
dragosmg opened this issue Dec 21, 2021 · 6 comments · Fixed by #2410
Closed

devtools::dev_sitrep() fails after the change in RStudio version numbering #2397

dragosmg opened this issue Dec 21, 2021 · 6 comments · Fixed by #2410

Comments

@dragosmg
Copy link

I was able to check this on 2 separate machines (both running macOS Monterey 12.1). Older machine running RStudio 1.4.1717 and an M1 Mac running RStudio v 2021.9.0.351.

It looks like devtools:::check_for_rstudio_updates() errors with HTTP status was 400 after the change in version numbering style.

devtools::dev_sitrep()
Error in utils::download.file(url, tmp, quiet = TRUE) : 
  cannot open URL 'https://www.rstudio.org/links/check_for_update?version=2021.9.0.351&os=darwin&format=kvp'
In addition: Warning message:
In utils::download.file(url, tmp, quiet = TRUE) :
  cannot open URL 'https://www.rstudio.org/links/check_for_update?version=2021.9.0.351&os=darwin&format=kvp': HTTP status was '400 Bad Request'
Error: [ENOENT] Failed to remove '/var/folders/r9/kvvr87vj4dngktkxksjf_5g80000gn/T/RtmpJhqLSV/filead4862b00739': no such file or directory

I was able to replicate this on an Intel Mac running RStudio 2021.9.372 (after updating from v 1.4.1717). dev_sitrep() worked fine before the update.

devtools::dev_sitrep()
Error in utils::download.file(url, tmp, quiet = TRUE) : 
  cannot open URL 'https://www.rstudio.org/links/check_for_update?version=2021.9.1.372&os=darwin&format=kvp'
In addition: Warning message:
In utils::download.file(url, tmp, quiet = TRUE) :
  cannot open URL 'https://www.rstudio.org/links/check_for_update?version=2021.9.1.372&os=darwin&format=kvp': HTTP status was '400 Bad Request'
Run `rlang::last_error()` to see where the error occurred.
Error: [ENOENT] Failed to remove '/var/folders/wx/zjw1jzk11s76vchhc2xym7xw0000gn/T/RtmpUcW8QW/file1056659aa557b': no such file or directory
Run `rlang::last_error()` to see where the error occurred.

Strangely, when trying to create a reprex, both reprexes seems to be running fine.
M1 Mac:

library(devtools)
#> Loading required package: usethis

devtools::dev_sitrep()
#> ── R ───────────────────────────────────────────────────────────────────────────
#> • version: 4.1.2
#> • path: '/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/'
#> ── devtools ────────────────────────────────────────────────────────────────────
#> • version: 2.4.3
#> ── dev package ─────────────────────────────────────────────────────────────────
#> • package: <unset>
#> • path: <unset>
#> ✓ All checks passed

Created on 2021-12-21 by the reprex package (v2.0.1)

And older Intel Mac:

library(devtools)
#> Loading required package: usethis

devtools::dev_sitrep()
#> ── R ───────────────────────────────────────────────────────────────────────────
#> • version: 4.1.1
#> • path: '/Library/Frameworks/R.framework/Versions/4.1/Resources/'
#> • R is out of date (4.1.1 vs 4.1.2)
#> ── devtools ────────────────────────────────────────────────────────────────────
#> • version: 2.4.3.9000
#> • devtools or its dependencies out of date:
#>   'glue', 'xfun', 'knitr', 'pkgbuild', 'openssl'
#>   Update them with `devtools::update_packages("devtools")`
#> ── dev package ─────────────────────────────────────────────────────────────────
#> • package: <unset>
#> • path: <unset>

Created on 2021-12-21 by the reprex package (v2.0.1)

@dragosmg
Copy link
Author

tmp <- fs::file_temp()
url <- "https://www.rstudio.org/links/check_for_update?version=2021.9.0.351&os=darwin&format=kvp"
utils::download.file(url, tmp, quiet = FALSE)
#> Warning in utils::download.file(url, tmp, quiet = FALSE):
#> cannot open URL 'https://www.rstudio.org/links/check_for_update?
#> version=2021.9.0.351&os=darwin&format=kvp': HTTP status was '400 Bad Request'
#> Error in utils::download.file(url, tmp, quiet = FALSE): cannot open URL 'https://www.rstudio.org/links/check_for_update?version=2021.9.0.351&os=darwin&format=kvp'
readLines(tmp)
#> Warning in file(con, "r"): cannot open file '/var/folders/r9/
#> kvvr87vj4dngktkxksjf_5g80000gn/T/RtmpURWZS6/fileb0051585e7de': No such file or
#> directory
#> Error in file(con, "r"): cannot open the connection

tmp2 <- fs::file_temp()
url2 <- "https://www.rstudio.org/links/check_for_update?version=1.4.1717&os=darwin&format=kvp"
utils::download.file(url2, tmp2, quiet = FALSE)
readLines(tmp2)
#> Warning in readLines(tmp2): incomplete final line found on '/var/folders/r9/
#> kvvr87vj4dngktkxksjf_5g80000gn/T/RtmpURWZS6/fileb005a39aadc'
#> [1] "update-version=&update-url=&update-message=&update-urgent=0"

Created on 2021-12-21 by the reprex package (v2.0.1)

@jennybc
Copy link
Member

jennybc commented Feb 22, 2022

I've asked the IDE team for advice on updating this URL or, perhaps, the whole strategy for determining whether to suggest an RStudio update.

This is the helper in question:

devtools/R/sitrep.R

Lines 5 to 42 in 41280ac

check_for_rstudio_updates <- function(os = tolower(Sys.info()[["sysname"]]), version = rstudioapi::getVersion(), in_rstudio = rstudioapi::isAvailable()) {
if (!in_rstudio) {
return()
}
url <- sprintf("https://www.rstudio.org/links/check_for_update?version=%s&os=%s&format=%s", version, os, "kvp")
tmp <- file_temp()
on.exit(file_delete(tmp))
utils::download.file(url, tmp, quiet = TRUE)
result <- readLines(tmp, warn = FALSE)
result <- strsplit(result, "&")[[1]]
result <- strsplit(result, "=")
# If no values then we are current
if (length(result[[1]]) == 1) {
return()
}
nms <- vcapply(result, `[[`, 1)
values <- vcapply(result, function(x) utils::URLdecode(x[[2]]))
result <- stats::setNames(values, nms)
if (!nzchar(result[["update-version"]])) {
return()
}
return(
sprintf("%s.\nDownload at: %s",
result[["update-message"]],
ui_field(result[["update-url"]])
)
)
}

@jennybc
Copy link
Member

jennybc commented Feb 22, 2022

You won't see the problem inside reprex::reprex() because that runs in a separate process and devtools never hits the RStudio-version-checking code in that case.

jennybc added a commit that referenced this issue Feb 23, 2022
* Adjust to new RStudio version numbering

Closes #2397

* Make this more resilient

* Account for older RStudio versions that do not expose `long_version`

* Append `&manual=true` to the URL

* Add tests

* Test with "darwin" (because that's what we send) and "windows"

* Message if download fails

In the future, this gives us a better chance of detecting if this function has stopped working again and shows the version number it's falling over for.

* Add NEWS bullet
@dragosmg
Copy link
Author

Thank you.

@jacobspangler-agendia
Copy link

I'm still getting this error in windows:

devtools::dev_sitrep()

Error in utils::download.file(url, tmp, quiet = TRUE) :
cannot open URL 'https://www.rstudio.org/links/check_for_update?version=2022.2.2.485&os=windows&format=kvp'
In addition: Warning message:
In utils::download.file(url, tmp, quiet = TRUE) :
cannot open URL 'https://www.rstudio.org/links/check_for_update?version=2022.2.2.485&os=windows&format=kvp': HTTP status was '400 Bad Request'

@jennybc
Copy link
Member

jennybc commented May 31, 2022

@jacobspangler-agendia I suggest you open a new issue

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants