Skip to content

Confusing error message: Error in envRefInferField(): ‘short’ is not a valid field or method name for reference class “Argument” #49

@tanho63

Description

@tanho63

Hiya! I think something weird is happening with the docopt error message generator as of the latest (0.7.2) update, here's a reprex:

docopt::docopt(
  doc = "
  run_script.R
  Usage:
    script [-x=<x> -y=<y> -z]
  Options:
    -x= --x_arg=<x> x argument
    -y= --y_arg=<y> y argument
    -z  --z_arg z argument
  ",
  args = "-x -y pie"
)
# Error in `envRefInferField()`:
# ! ‘short’ is not a valid field or method name for reference class “Argument”

I realize that the user has misspecified the -x arg here, but I'm assuming the error logic is meant act more like what happens when you pass in -x pie -y as the arg:

Error in `parse_shorts()`:
! -yrequires argument

I super appreciate the effort in adding this error handling though, it was very confusing to debug input errors previously since it just printed the help doc without saying what exactly was wrong.

session info
R> sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.1 (2024-06-14)
 os       Ubuntu 22.04.4 LTS
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  C.UTF-8
 ctype    C.UTF-8
 tz       America/Los_Angeles
 date     2025-04-08
 pandoc   2.9.2.1 @ /usr/bin/pandoc

─ Packages ─────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 cachem        1.1.0   2024-05-16 [1] RSPM
 cli           3.6.4   2025-02-13 [1] RSPM
 devtools    * 2.4.5   2022-10-11 [2] RSPM
 digest        0.6.37  2024-08-19 [1] RSPM
 docopt        0.7.2   2025-03-25 [1] RSPM
 ellipsis      0.3.2   2021-04-29 [2] RSPM (R 4.4.0)
 fastmap       1.2.0   2024-05-15 [1] RSPM
 fs            1.6.5   2024-10-30 [1] RSPM
 glue          1.8.0   2024-09-30 [1] RSPM
 htmltools     0.5.8.1 2024-04-04 [1] RSPM
 htmlwidgets   1.6.4   2023-12-06 [1] RSPM
 httpuv        1.6.15  2024-03-26 [2] RSPM (R 4.4.0)
 later         1.4.1   2024-11-27 [1] RSPM
 lifecycle     1.0.4   2023-11-07 [1] RSPM
 logger        0.4.0   2024-10-22 [1] RSPM
 magrittr      2.0.3   2022-03-30 [1] RSPM
 memoise       2.0.1   2021-11-26 [1] RSPM
 mime          0.13    2025-03-17 [1] RSPM
 miniUI        0.1.1.1 2018-05-18 [2] RSPM (R 4.4.0)
 pkgbuild      1.4.4   2024-03-17 [2] RSPM (R 4.4.0)
 pkgload       1.3.4   2024-01-16 [2] RSPM (R 4.4.0)
 profvis       0.3.8   2023-05-02 [2] RSPM (R 4.4.0)
 promises      1.3.2   2024-11-28 [2] RSPM
 purrr         1.0.4   2025-02-05 [1] RSPM
 R6            2.6.1   2025-02-15 [1] RSPM
 Rcpp          1.0.14  2025-01-12 [1] RSPM
 remotes       2.5.0   2024-03-17 [2] RSPM (R 4.4.0)
 rlang         1.1.5   2025-01-17 [1] RSPM
 rstudioapi    0.17.1  2024-10-22 [1] RSPM
 sessioninfo   1.2.2   2021-12-06 [2] RSPM (R 4.4.0)
 shiny         1.10.0  2024-12-14 [2] RSPM
 stringi       1.8.7   2025-03-27 [1] RSPM
 stringr       1.5.1   2023-11-14 [1] RSPM
 urlchecker    1.0.1   2021-11-30 [2] RSPM (R 4.4.0)
 usethis     * 3.1.0   2024-11-26 [2] CRAN (R 4.4.1)
 vctrs         0.6.5   2023-12-01 [1] RSPM
 xtable        1.8-4   2019-04-21 [2] RSPM (R 4.4.0)

 [1] /home/tan/R/x86_64-pc-linux-gnu-library/4.4
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions