r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 753 forks source link

`devtools::dev_sitrep()` failing on Windows system #2434

Closed jacobspangler-agendia closed 2 years ago

jacobspangler-agendia commented 2 years ago

When I use the devtools::dev_sitrep() function, I'm getting a 400 bad request response:

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'

This appears similar to issue 2397

jennybc commented 2 years ago

@jgutman does the above surprise you?

jgutman commented 2 years ago

Off the top of my head I don't know why this would be, but I'll take a look soon!

jennybc commented 2 years ago

I definitely get the same 400:

httr::GET("https://www.rstudio.org/links/check_for_update?version=2022.2.2.485&os=windows&format=kvp")
#> Response [https://www.rstudio.org/links/check_for_update?version=2022.2.2.485&os=windows&format=kvp]
#>   Date: 2022-06-02 22:41
#>   Status: 400
#>   Content-Type: text/html; charset=UTF-8
#> <EMPTY BODY>

so the question really is ... is devtools making a bad URL or does some URL that should work, not work?

jennybc commented 2 years ago

I wonder if this particular build (2022.2.2.485) was removed or de-listed as part of the response to this:

PSA: If you're using @RStudio with R 4.2 on Windows, please update to the just-released 2022.02.3. There's an issue with R 4.2 and older @RStudio releases that can empty your R scripts

https://twitter.com/rstudiotips/status/1532775784632356865

jgutman commented 2 years ago

No, we literally just released that patch, so that isn't the reason. I will be evaluating this, its just been busy this week. I've confirmed it gives the correct response in RStudio Desktop on Windows with 2022.2.2.485, so I'll compare and see if we are pinging the same URL with the same params -- will get back to this next week!

jgutman commented 2 years ago

Okay, so I have identified the issue, and it does appear that the correct URL is not being formed. IIRC, the PR we had previously discussed, the intended approach was to call rstudioapi::versionInfo()$long_version and use the long version in constructing the URL. Because some older versions of RStudio do not have a long version, if there was no long version, fall back to the rstudioapi::versionInfo()$version. For the identified version, the long version is 2022.02.2+485, and we should be using the escaped long version, rather than the (short) version, which is 2022.2.2.485 and does not exist on the page. I'm not sure offhand why it is using the version rather than the long version, but I believe that is the source of the error

jgutman commented 2 years ago

@jacobspangler-agendia do you get the same error with the latest development version of devtools from Github? It seems like this fails using the version of devtools on CRAN, but passes if I install from Github.

image
jennybc commented 2 years ago

Ah, yes. I haven't released devtools to CRAN since implementing the fix for this function!

https://github.com/r-lib/devtools/blob/main/NEWS.md#devtools-development-version