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

Cannot find module name for "mod_mod_XXX" type module names [BUG] #997

Closed
ilyaZar opened this issue Mar 2, 2023 · 2 comments
Closed

Cannot find module name for "mod_mod_XXX" type module names [BUG] #997

ilyaZar opened this issue Mar 2, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ilyaZar
Copy link
Contributor

ilyaZar commented Mar 2, 2023

Describe the bug
If user accidently uses golem::add_module("mod_99_tests", fct = "some_test_funs") this creates:

  1. Probably unwanted module name "mod_mod_XXXX"; happens to me at least because I keep forgetting this behaviour after a while and then have to rename files and modules
  2. the following error
File created at R/mod_mod_99_tests.R
Error: The module '99_tests' does not exist.
You can call `golem::add_module('99_tests')` to create it.
Called from: add_r_files(name, module, ext = "fct", pkg = pkg, open = open, 
    dir_create = dir_create, with_test = with_test)

That is because internally, the add_r_files() deletes the mod_-part but then cannot find the correct module name.

To Reproduce
Steps to reproduce the behavior:

  1. golem::add_module("mod_99_tests", fct = "some_test_funs") ; fct or utils arguments must be provided

Expected behavior
Either fix the internal add_r_files() to correctly find the module name in this "buggy"/"esoteric" case or make a name syntax check explicit as one could assume that the user actually wanted to have module named "mod_" without double prefix "mod_mod".

I made a branch on my fork implementing the latter, as I found it difficult to believe that someone really wants a module named "mod_mod_XXX" but who knows.

session info

> sessioninfo::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.2 Patched (2022-11-10 r83330)
 os       Linux Mint 20
 system   x86_64, linux-gnu
 ui       RStudio
 language en_US
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Berlin
 date     2023-03-02
 rstudio  2022.07.2+576 Spotted Wakerobin (desktop)
 pandoc   NA

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
attempt 0.3.1 2020-05-03 [1] CRAN (R 4.0.2)
cli 3.6.0 2023-01-09 [1] CRAN (R 4.2.2)
config 0.3.1 2020-12-17 [1] CRAN (R 4.0.3)
desc 1.4.2 2022-09-08 [1] CRAN (R 4.2.2)
digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.2)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0)
fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.2)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.4)
fs 1.6.1 2023-02-06 [1] CRAN (R 4.2.2)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.3)
golem 0.3.5.9001 2023-03-02 [1] local
here 1.0.1 2020-12-13 [1] CRAN (R 4.2.2)
htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.2.2)
httpuv 1.6.9 2023-02-14 [1] CRAN (R 4.2.2)
later 1.3.0 2021-08-18 [1] CRAN (R 4.1.1)
lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.1)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.1)
mime 0.12 2021-09-28 [1] CRAN (R 4.1.1)
pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.1)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.0.4)
purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.2)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.1)
Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.2.2)
rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.1)
rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.1.3)
rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.2)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.3)
shiny 1.7.4 2022-12-15 [1] CRAN (R 4.2.2)
tibble 3.1.8 2022-07-22 [1] CRAN (R 4.2.1)
usethis 2.1.6 2022-05-25 [1] CRAN (R 4.2.1)
utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.2)
vctrs 0.5.2 2023-01-23 [1] CRAN (R 4.2.2)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.0.2)
yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.2)

[1] /home/iz/Dropbox/libraries/R/4.0
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library

@ilyaZar ilyaZar added the bug Something isn't working label Mar 2, 2023
@ilyaZar ilyaZar changed the title Cannot find module name for "mod_mod_XXX" type module names [BUG] [FR] Cannot find module name for "mod_mod_XXX" type module names [BUG] Mar 2, 2023
@ilyaZar
Copy link
Contributor Author

ilyaZar commented Mar 2, 2023

I am happy to PR from ilyaZar@a20b081 if that is relevant

@ilyaZar ilyaZar mentioned this issue Mar 24, 2023
@ColinFay
Copy link
Member

Closed via #1035

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants