Matlabstan - "Having a problem getting stan version."

Operating System: Windows 10, Matlab 2019b
Interface Version: Matlabstan 2.15.10, cmdstan v2.21.0
Compiler/Toolkit: mingw64

Running the 8 schools example gives me the following:

Having a problem getting stan version.
This is likely a problem with Java running out of file descriptors
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Giving up.
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set ‘UniformOutput’ to false.
Error in StanModel/stan_version (line 850)
ver = cellfun(@str2num,regexp(str{3},’.’,‘split’));
Error in StanModel (line 196)
ver = self.stan_version();
Error in stan (line 108)
model = StanModel();
Error in tester (line 29)
fit = stan(‘model_code’,schools_code,‘data’,schools_dat);

[status,cmdout] = system(‘stanc.exe --version’)
status =
cmdout =
'stanc acfb4612 (Win32)

I have found the topics below. There is no space in file path and matlabprocessmanager runs fine. I don’t know how to continue. Help?


From the output it looks to me that stanc is not on PATH. Hence it’s not able to just run it from a new shell. I think you can solve this by adding the cmdstan bin folder to your “Environment variables” in Windows.

cmdstan/bin is in the path.

output from cmd:

stanc --version
stanc acfb4612 (Win32)

Hi rainfern, I am having the exact same issue (except on Mac OS). Have you figured out a fix yet? Thanks!

I just switched from cmdstan-2.23.0 to cmdstan-2.17-1. Now there’s no issue anymore. It seems like the new cmdstan doesn’t work well with MatlabStan, which hasn’t been updated for quite a while.


I am running cmdstan in Matlab R2019b on a Mac OS. Switching from cmdstan-2.23.0 to cmdstan-2.17-1 solved my problem as well. Thanks Jimmy_Xia!

Whatever matlab stan is expecting as the version, it’s not what the Stanc3 compiler is returning -
reopened this issue:

The 2.23 release is returning this:

bin/stanc --version
stanc3 f556d0d (Unix)

What does MatLabStan expect?

As I can see matlabstan does not support mingw32-make so 2.21 definitely does not work out of the box, at least not on Windows. So 2.22 and 2.23 that both use stanc3 also dont work.

I am not sure if we want to change the version output back. The original reason of why we added the 3 to the version number in the --version output is that both STANC2 and stanc3 binaries were named bin/stanc. That reason is not there right now, that is true.

That is probably something we missed during the release (this should say stanc3 v2.23 (Unix)). That is how it was for 2.22.

If we changed the version output back, both would say

stanc v2.23 (Unix)

but they are not the same. Stanc3 has additional signatures along with other differences:
So I dont think they should both output the same version.

Unfortunately, I think the best solution would be for someone to fork the matlabstan repo and fix this issue along with the mingw32-make thing. One easy trick to make 2.22/2.23 work is using stanc2 (see

I can assist if help is needed but my Matlab/Octave skills are stuck in my undergrad years and I dont plan on reviving them anytime soon :)


@serban-nicusor - is this something that needs to go into the release script?

I ran into the same issue. For anyone interested, an ugly workaround is to comment out the function stan_version() in StanModel.m and replace it with

function ver = stan_version(self)
ver = [2 26 1];

for version stanc3 v2.26.1 (Unix).

1 Like