Obtaining the CVX version programmatically

I am writing a library that uses CVX. I would like to obtain the CVX build number programmatically so that I can verify that my users’ CVX installations are recent enough.

Surprisingly, CVX seems to provide no structured way to retrieve this information. But no matter–I wrote a simple regex to extract the build number from the output of cvx_version. Here is where things get really weird. Calling cvx_version seems to break my CVX installation. Specifically, after calling cvx_version, CVX gives error like

Non-overloaded subscripting can produce only one result.

Error in cvxprob/solve (line 423)
            [ x, status, tprec, iters, y ] = shim.solve( At, b, c, cones, quiet, prec, solv.settings, eargs{:} );

Error in cvx_end (line 88)
        solve( prob );

To make these errors go away, I have to call cvx_setup. What is going on here?

I think I know what’s going on. I have a fix for 3.0 beta, and can probably backport it to 2.1 as well.

But if your goal is to verify that they are using a sufficiently recent version of CVX, you won’t be able to use your strategy, because of course it will break CVX for those users that don’t have my bug fix in place.

A better choice would be to parse the cvx_version file itself. I actually do this in the cvx_sedumi shim in order to determine what version of SeDuMi is being used! I’d do something like this:

global cvx___
fid = fopen( [ cvx___.where, cvx___.fs, 'cvx_version.m' ] );
tmp = fread( fid, Inf, 'uint8=>char' )';
tmp = regexp( otp, 'cvx_bld = ''['']*''', 'match' );

This should work in both 2.x and 3.x. Heck it might even work in version 1.x. Obviously, you should customise this for your needs.

The solution posted by mcg works. For future reference, I have to call cvx_version(1) first to set the cvx___ global.