CmdStan.jl fails on documentation example - path issues

I’m trying to run the basic example in the CmdStan.jl documentation.

However, I’m getting path related errors.

When I try to specify the project folder in the call to stan:

using CmdStan
set_cmdstan_home!(“/Users/yanivabir/cmdstan”)

bernoullistanmodel = "
data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
}
parameters {
real<lower=0,upper=1> theta;
}
model {
theta ~ beta(1,1);
y ~ bernoulli(theta);
}
"

stanmodel = Stanmodel(name=“bernoulli”, model=bernoullistanmodel);

bernoullidata = Dict(“N” => 10, “y” => [0, 1, 0, 1, 0, 0, 0, 0, 0, 1])

rc, chns, cnames = stan(stanmodel, bernoullidata, “/Path/to/folder”)

I get the following error:

An error occurred while compiling the Stan program.

Please check your Stan program in variable ‘bernoulli’ and the contents of /Path/to/folder/tmp/bernoulli_build.log.
Note that Stan does not handle blanks in path names.

A tmp folder is made in my project folder, with the files bernoulli.stan, bernoulli_build.log and bernoulli_make.log in it.

When I don’t try to specify the project directory, the stan program compiles, samples are drawn and saved to csv (inside a tmp folder in my cmdstan folder), but then CmdStan.jl gives an error:

I run:

using CmdStan
set_cmdstan_home!(“/Users/yanivabir/cmdstan”)

bernoullistanmodel = "
data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
}
parameters {
real<lower=0,upper=1> theta;
}
model {
theta ~ beta(1,1);
y ~ bernoulli(theta);
}
"

stanmodel = Stanmodel(name=“bernoulli”, model=bernoullistanmodel);

bernoullidata = Dict(“N” => 10, “y” => [0, 1, 0, 1, 0, 0, 0, 0, 0, 1])

rc, chns, cnames = stan(stanmodel, bernoullidata)

and get:

Base.IOError(“could not spawn /Users/yanivabir/cmdstan/bin/stansummary --csv_file=bernoulli_summary.csv bernoulli_samples_1.csv bernoulli_samples_2.csv bernoulli_samples_3.csv bernoulli_samples_4.csv: no such file or directory (ENOENT)”, -2)
Stan.jl caught above exception in Stan’s ‘stansummary’ program.
This is a usually caused by the setting:
Sample(save_warmup=true, thin=n)
in the call to stanmodel() with n > 1.

Looking at the folder, the four sample csv files are there, but there is not summary.csv file.
It then prints chns as if everything is ok.

Any help much appreciated!

The problem was that stan doesn’t accept any spaces in paths. So setting the project directory, tmp directory and CmdStan directories to paths without spaces in them solved this.

3 Likes