Closed andrewjradcliffe closed 10 months ago
all of these problems could be solved by using Boost filesystem library, but it's not a header-only library, which will complicated the build process. without Boost filesystem, we can kludge up checks.
all of these problems could be solved by using Boost filesystem library, but it's not a header-only library, which will complicated the build process. without Boost filesystem, we can kludge up checks.
An alternative could be the std library filesystem, but that requires C++17 (still get to stay header-only at least!)
Summary:
As noted in this issue, the treatment of paths as strings in CmdStan can lead to strange behavior.
Description:
Treating a string as a path, and subsequently splitting on last dot produces a family of problems.
Reproducible Steps:
I am certain that more examples can be produced, but here are a few interesting cases.
Assuming that you have the bernoulli example built and your current directory is
examples/bernoulli/bernoulli
:Case 1
Case 2
Debug of Case 2
CmdStan is splitting on the
'.'
and producing output file names of the formfoo/_${id}.bar/baz
and since_${id}.bar
is a non-existent directory, no files are created. If we create said directories ahead of time, the writer succeeds.Case 3
Current Output:
Summarized from reproducer above:
num_chains == 1
num_chains > 1
foo.bar/baz
foo.bar/baz
foo/.bar/baz
foo/.bar/baz
foo/_${id}.bar/baz
iff pre-existingfoo/_${id}.bar
directory'foo/bar/..'
foo/bar/._${id}.
Expected Output:
num_chains == 1
num_chains > 1
foo.bar/baz
foo.bar/baz.csv
foo.bar/baz_${id}.csv
foo/.bar/baz
foo/.bar/baz.csv
foo/.bar/baz_${id}.csv
'foo/bar/..'
One could argue that the errors should be handled by substituting the default file name after path normalization, but it is ill-formed as a directory was provided when a file was required.
Additional Information:
Current Version:
v2.33.1