cmdstanR cannot find fit output files if stan file has a space in name

It appears that cmdstanR will not work if stan files have a space in the name. Here I’m using the famous 8 schools example to illlustrate the issue. Saving the model file as schools.stan works exactly as expected. Saving it as “schools with space.stan” does not and returns Error: Supplied CSV file is corrupt!:

> file <- "examples/schools with space.stan"
> mod_sch <- cmdstan_model(file)
> fit_mcmc <- mod_sch$sample(data = schools_dat, seed = 123, chains = 2, parallel_chains = 2)
Running MCMC with 2 parallel chains...
<removed chain status updates for brevity>
Chain 1 finished in 0.1 seconds.
Chain 2 finished in 0.1 seconds.

Both chains finished successfully.
Mean chain execution time: 0.1 seconds.
Total execution time: 0.2 seconds.
grep: /tmp/RtmpYguSPm/schools: No such file or directory
grep: with: No such file or directory
grep: space-202102091644-1-5c8e67.csv: No such file or directory
Error: Supplied CSV file is corrupt!
> fit_mcmc$output_files()
Error: object 'fit_mcmc' not found

/tmp/RtmpYguSPm/‘schools with space-202102091644-1-5c8e67.csv’ does exist in my file system.

Running cmdstanr 0.3.0 with cmdstan 2.26.0

1 Like

Make an issue on the Cmdstanr Github: Issues · stan-dev/cmdstanr · GitHub

Some of these names with spaces bugs are a trick to fix, but this should be written down somewhere.

Thanks for reporting. Bug fix PR open: Fix issue with reading in CSV for models with spaces in name by rok-cesnovar · Pull Request #453 · stan-dev/cmdstanr · GitHub

1 Like