Saving metric files in cmdstanr

Is there a known problem with saving metric files in cmdstanr? Saving all other types of outputs works fine, but fit$save_metric_files() always gives a cryptic error:

> library(cmdstanr)
> fit = cmdstanr_example()
Model executable is up to date!
> fit$save_metric_files(dir="C:/",basename="asdf")
Error in file.remove(current_files[!current_files %in% new_paths]) :
  invalid first filename

Explicitly wrapping this in a traceback statement in an R script only gives No traceback available, because the culprit seems to be wrapped in anonymous functions -> <Anonymous> -> <Anonymous> -> file.remove.

Iā€™ve tried this on multiple machines, with all possible permutations of input arguments and working directories. Is this a known problem?

Can you try adding save_metric=TRUE when fitting the model? I think the doc just needs to be clearer that this isnā€™t the default and the error message needs to be clearer that it couldnā€™t find the files.

Edit: I see the doc says that the default is TRUE but it seems to not be the case.

1 Like

Wonderful, thanks Jonah!

1 Like

Thanks for pointing this out! I just opened a pull request to fix the doc and add a better error message: