MichaelChirico / potools

Tools for working with translations in R
https://michaelchirico.github.io/potools/
58 stars 3 forks source link

system2 error when calling po_create #288

Closed LDalby closed 2 years ago

LDalby commented 2 years ago

Hi

In an attempt to fix https://github.com/r-lib/pkgdown/issues/1985 I'm getting an error when calling potools::po_create(). I can't really figure out how to debug this one. Any help would be greatly appreciated!

#>   potools::po_create("dk")
Creating 'dk' R translation
Error in system2("msginit", args, stdout = TRUE, stderr = TRUE) : 
  error in running command
Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.1.2 (2021-11-01) #> os Ubuntu 20.04.3 LTS #> system x86_64, linux-gnu #> ui X11 #> language en_US:en #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Copenhagen #> date 2022-01-05 #> pandoc 2.11.4 @ /usr/lib/rstudio/bin/pandoc/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.2) #> cli 3.1.0 2021-10-27 [3] CRAN (R 4.1.1) #> crayon 1.4.2 2021-10-29 [3] CRAN (R 4.1.1) #> data.table 1.14.2 2021-09-27 [1] CRAN (R 4.1.1) #> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2) #> ellipsis 0.3.2 2021-04-29 [3] CRAN (R 4.0.5) #> evaluate 0.14 2019-05-28 [3] CRAN (R 4.0.0) #> fansi 0.5.0 2021-05-25 [1] CRAN (R 4.1.0) #> fastmap 1.1.0 2021-01-25 [3] CRAN (R 4.0.3) #> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.2) #> glue 1.6.0 2021-12-17 [1] CRAN (R 4.1.2) #> highr 0.9 2021-04-16 [3] CRAN (R 4.0.5) #> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.1) #> knitr 1.37 2021-12-16 [3] CRAN (R 4.1.2) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.1) #> magrittr 2.0.1 2020-11-17 [3] CRAN (R 4.0.3) #> pillar 1.6.4 2021-10-18 [1] CRAN (R 4.1.1) #> pkgconfig 2.0.3 2019-09-22 [3] CRAN (R 4.0.0) #> potools * 0.2.3 2022-01-04 [1] Github (MichaelChirico/potools@c6d6dd5) #> purrr 0.3.4 2020-04-17 [3] CRAN (R 4.0.0) #> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.0) #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.0) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.0) #> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.1) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.0) #> rlang 0.99.0.9003 2022-01-04 [1] Github (r-lib/rlang@ce4aca5) #> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.1) #> rstudioapi 0.13 2020-11-12 [3] CRAN (R 4.0.3) #> sessioninfo 1.2.2 2021-12-06 [3] CRAN (R 4.1.2) #> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.2) #> stringr 1.4.0 2019-02-10 [3] CRAN (R 4.0.0) #> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.1) #> tibble 3.1.6 2021-11-07 [1] CRAN (R 4.1.2) #> utf8 1.2.2 2021-07-24 [3] CRAN (R 4.1.0) #> vctrs 0.3.8 2021-04-29 [3] CRAN (R 4.0.5) #> withr 2.4.3 2021-11-30 [1] CRAN (R 4.1.2) #> xfun 0.29 2021-12-14 [1] CRAN (R 4.1.2) #> yaml 2.2.1 2020-02-01 [3] CRAN (R 4.0.0) #> #> [1] /home/au206907/R/x86_64-pc-linux-gnu-library/4.1 #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```
MichaelChirico commented 2 years ago

Totally agree that's a super unhelpful error message :(

Could you try the following:

(1) share the output of msginit --version

(2) add the following verbose output & run again (it'll still fail, hopefully more helpfully):

trace(potools:::run_msginit, at=2, quote({writeLines(args); system2("msginit", args)}))
LDalby commented 2 years ago
 msginit --version

Command 'msginit' not found, but can be installed with:

sudo apt install gettext

After installing gettext I could run potools::po_create("dk") and got the expected result!

So maybe gettext should be a dependency so it will be installed during installation of potools? (Or the user would be notified that a dependency is missing)

LDalby commented 2 years ago

Thanks for the quick response btw!

MichaelChirico commented 2 years ago

I see... guess I filed #287 with perfect timing then!

extra detail: This is mainly a growing pain of the new dev functionality. The earlier workflow only had translate_package(), which runs potools::check_potools_sys_reqs() and would have caught this more helpfully. #287 will bring back the system tests to the new functions.

Thanks for filing! I'll leave this open to see if we can't improve the messaging somehow anyway.

LDalby commented 2 years ago

Yes, I did see #287 just now - good timing indeed 👍🏼