Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Error in if (latest_R_version == R_version) #170

Open
jessekps opened this issue Aug 3, 2022 · 6 comments
Open

Error in if (latest_R_version == R_version) #170

jessekps opened this issue Aug 3, 2022 · 6 comments

Comments

@jessekps
Copy link

jessekps commented Aug 3, 2022

When using create_app with usual arguments and include_R=TRUE I get the error:

Error in if (latest_R_version == R_version) { :
argument is of length zero

I believe the error is in get_R.R on line 23:

latest_R_version <- readLines("https://cran.rstudio.com/bin/windows/base/", warn = F) %>%
    stringr::str_extract("[1-3]\\.[0-9]+\\.[0-9]+") %>% stats::na.omit() %>% unique()

The regular expression should start with [1-4], since R4.+ is now the current R version.

@AmyMikhail
Copy link

Coming to say I still have the same issue in January 2023 - but also just wondering why the regular expression could not be dynamic - why isn't the first part of the regular expression just [0-9]? That would last a good while longer...

@jessekps
Copy link
Author

And if you don't feel like maintaining that code, you can simply rely on rversions. It seems to be actively maintained by some well known names in the R community.

> rversions::r_release()
version                date              nickname
4.2.2 2022-10-31 08:05:54 Innocent and Trusting

@vekinoir
Copy link

vekinoir commented Jan 4, 2024

I am facing the same error with create_app with argument include_R = TRUE, R_version = "4.0.0"

Error in if (latest_R_version == R_version) { : 
  argument is of length zero

However when I change the 3 to 4 in the latest_R_version in trace(RInno::get_R,edit=T) and trace(RInno::code_section,edit=T)

I am still getting an error

Error in if (latest_R_version == R_version) { : 
  the condition has length > 1

How to fix this?

@matdillen
Copy link

latest_R_version is extracted from the html at https://cran.rstudio.com/bin/windows/base/ That page now seems to include a commented reference to 4.3.0 beyond the most up to date build (4.4.0). Hence you get a vector instead of a string and the listed condition throws an error.

You can fix the functions by adding the following code before running them (but after loading rinno):

body(code_section)[[4]][[3]][[2]][[2]][[2]] <- substitute(
  stringr::str_extract(readLines("https://cran.rstudio.com/bin/windows/base/",
                                 warn = F), "[1-4]\\.[0-9]+\\.[0-9]+")
)
body(code_section)[[4]][[3]][[3]][[2]] <- substitute(
  stringr::str_extract(readLines("https://cran.rstudio.com/bin/windows/base/old/", 
                                 warn = F), "[1-4]\\.[0-9]+\\.[0-9]+")
)
body(get_R)[[4]][[3]][[2]][[2]][[3]] <- substitute(
  stringr::str_extract("[1-4]\\.[0-9]+\\.[0-9]+")
)
body(get_R)[[6]][[2]] <- substitute(
  latest_R_version[1] == R_version
)
body(get_R)[[5]][[3]][[2]][[3]] <- substitute(
  stringr::str_extract("[1-4]\\.[0-9]+\\.[0-9]+")
)

Ugly and still at risk of breaking in the future if the cran pages change or R 5 comes out, but it works for now.

@FrancoMSuarez
Copy link

@matdillen Could you explain this solution better to me please?

@matdillen
Copy link

You can see it implemented for example here: https://github.com/AgentschapPlantentuinMeise/MIDSCalculator/blob/main/src/rinno_installer.R

The above script updates the get_R and code_section functions of rinno in the R session to hotfix bugs with R version numbers. A regex in both functions only goes up to R version 3 and the latest R version extracted from CRAN's website now always includes R-4.3.0 as well because of the (commented) line in the html below. Hence the script gets a vector instead of a string and crashes.

<!--<li>A <a href="rtest.html">pre-release</a> version for the forthcoming R-4.3.0 is available.</li>-->

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

No branches or pull requests

5 participants