rr-usethis

`use_import_from' is not an exported object from 'namespace:usethis`


While developping an R package, I'm trying to use the function usethis::use_import_from() to import in the package a single function from another package but the function is not available whatever way I'm trying : loading usethis or devtools or explicitly writing the name with ::. It is not available in the help either. However, it is well documented here and I can see it in the source code here:

> usethis::use_import_from("stats", "runif")
Error: 'use_import_from' is not an exported object from 'namespace:usethis'

I am using RStudio 1.3.1056, R 4.0.4, usethis 2.0.1 on Windows 10 and RStudioServer 1.1.1717, R 4.1.0, usethis 2.0.1 on Linux and have the same problem on both.

I know that I could insert the line in the description myself but there seems to be a series of checks on this function that makes it more secure.

Anybody can help ?


Solution

  • The usethis::use_import_from() function is not in the released version 2.0.1 of usethis, it's in the development version on Github. Usually the online help page would indicate that, but in this case they've forgotten to flag it, so the page shows version 2.0.1.9000 (where the 9000 signals a development version in the scheme they use), but calls it a "Released version".

    If you want to use it anyway, you can install directly from Github instead of from CRAN using

    remotes::install_github("r-lib/usethis")
    

    Do be aware that since it's a development version, it hasn't been tested as carefully as the released version on CRAN. The bug in the web page won't cause much trouble now you know about it, but there may be others that are more serious.