RMarkdown: strange error: Error in validate_cmdstan_args(self) : Assertion on 'self$refresh' failed: Element 1 is not

I am testing an RMarkdown document that includes a Stan simulation run under cmdstanr. It fails when I try to execute this command:

Gfit <-   mod$sample(
    data = dsg,
    refresh = -1, 
    chains = n_chains,
    seed = 2, 
    init  = init_ll, 
    adapt_delta = 0.95,
    step_size = 0.1
  )

and this error message appears:

Error in validate_cmdstan_args(self) :
Assertion on ‘self$refresh’ failed: Element 1 is not >= 0.

The error message is quite incomprehensible so I don’t know where to look for the cause of the problem in my code.

I hesitate to post the whole code because it is very long but let me know if more is needed.

Basically it would be helpful just to know what the error message is about!

It’s trying to tell you that refresh needs to be non-negative, but I agree that it’s not the clearest message. We use the checkmate package to help with checking all the user supplied arguments before they are passed to CmdStan. It’s a really useful package and it saved us a lot of time, but the messages it generates sometimes aren’t as clear as they should be. Maybe we need to consider a different approach.

Thank you, Jonah. It will be easy for me to sort out my code - easier than sorting out the checkmate messages.