Skip to content

Select one of several installed OpenModelica versions - #5

Merged
adrpo merged 2 commits into
OpenModelica:masterfrom
adrpo:omhome-version
Nov 18, 2026
Merged

adrpo merged 2 commits into
OpenModelica:masterfrom
adrpo:omhome-version

Conversation

@adrpo

@adrpo adrpo commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Client part of OpenModelica/OpenModelica#5809 (several OpenModelica versions installed side by side on Windows).

With OpenModelica/OpenModelicaSetup#96 the Windows installer keeps OPENMODELICAHOME for the version selected as the default one and sets OPENMODELICAHOME_<version> for each installed version, with every character of the version that is not a letter or a digit replaced by an underscore, e.g. OPENMODELICAHOME_1_27_0.

What changes

The constructor takes the version as a second argument:

omc = OMOctave('', '1.27.0');   % exactly this version
omc = OMOctave('', '1.27');     % the newest installed 1.27.x
OMOctave.installedVersions()    % what is installed, newest first

OpenModelica is looked for in this order:

  1. the omcpath argument
  2. the version argument; an error with the list of the installed versions if it is not installed
  3. on Windows, OPENMODELICAHOME
  4. on Windows, the newest OPENMODELICAHOME_<version>
  5. omc from the PATH

"Newest" compares the numbers of the version: for the same major.minor.patch a pre-release build (1.28.0-dev-…) is older than the release, which is older than a build after it (1.27.0-5-g…). The lookup functions are the same as in OpenModelica/OMMatlab#33, and the order is the one of OpenModelica/OMPython#490.

Four fixes that come with it:

  • The session remembers its installation directory and simulate() takes the DLL path on Windows from it. It used OPENMODELICAHOME, which is the wrong installation for a session started with omcpath (and now with version).
  • On Windows without OPENMODELICAHOME, omc from the PATH is started; before, the command was /bin/omc.exe.
  • On Windows the path of omc is quoted in the START command. Without the quotes an installation in a directory with a space in its name, as the default C:\Program Files\OpenModelica<version> has, was not started: Windows reported that it cannot find the part of the path before the space.
  • On Windows omc is started with the async type of system. With Octave 11.3 system('START /b ...omc.exe ...') did not return while omc was running, so the constructor never got to read the port file. master hangs in the same way there.

Linux and macOS start omc from the PATH as before unless omcpath or version is given.

Testing

GNU Octave 10.3 on Linux:

  • 28 checks of the lookup functions with directories that contain an empty bin/omc.exe (exact version, start of a version, version that is not installed, default, uninstalled default, newest, real environment variables).
  • OMOctave('', '1.99') with OPENMODELICAHOME_1_99_0=/usr starts /usr/bin/omc (the port file is created). The constructor then stops at pkg load zeromq, which I could not install, so no expression was sent.
  • OMOctave('', '1.0') gives the error with the installed versions.

GNU Octave 11.3 with zeromq 1.5.7 on Windows 11, octave-cli, with an omc 1.28.0-dev built from source. Each session checks getVersion() and getInstallationDirectoryPath(), builds a bouncing ball model with ModelicaSystem, runs simulate() and reads the result with getSolutions:

  • The same 28 checks of the lookup functions.
  • OPENMODELICAHOME_1_27_0 (a directory with an empty bin\omc.exe) and OPENMODELICAHOME_1_28_0_dev_... pointing to C:\temp\omoct\OM 1.28 (a junction to the real installation, with a space in the name), no OPENMODELICAHOME: OMOctave() and OMOctave('', '1.28') both run the 1.28 one; OMOctave('', '1.26') gives the error with the installed versions.
  • OPENMODELICAHOME pointing to a directory without omc plus the versioned variable: the versioned installation is used.
  • Only OPENMODELICAHOME: used as before.
  • No variable at all and omc in the PATH: omc from the PATH is used.
  • OMOctave(omcpath) with the full path of omc.exe (written with / and with \), without any variable and with OPENMODELICAHOME pointing to a directory without omc: the given omc is used, as before. The same with the path through the junction with the space in its name.

Not tested: the Octave GUI, and macOS.


🤖 Generated with Claude Code

@adrpo adrpo self-assigned this Nov 17, 2026
The Windows installer is changed to allow several OpenModelica versions
side by side (OpenModelica/OpenModelica#5809,
OpenModelica/OpenModelicaSetup#96). OPENMODELICAHOME then points to the
default one and each version sets OPENMODELICAHOME_<version>, with the
characters of the version that are not letters or digits replaced by
underscores (OPENMODELICAHOME_1_27_0).

OMOctave(omcpath, version) takes the version as second argument and
looks for OpenModelica in this order:

1. the omcpath argument
2. the version argument: OPENMODELICAHOME_<version>, or the newest
   installed version that starts with it ('1.27' for the newest 1.27.x)
3. on Windows, OPENMODELICAHOME
4. on Windows, the newest OPENMODELICAHOME_<version>
5. omc from PATH

The session remembers its installation directory, and simulate() takes
the DLL path on Windows from it instead of from OPENMODELICAHOME, which
is the wrong one for a session started with omcpath or version. On
Windows without OPENMODELICAHOME omc from PATH is started instead of
/bin/omc.exe.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two problems found when running on Windows (Octave 11.3) with an
installation in a directory with a space in its name, as the default
C:\Program Files\OpenModelica<version> has
(OpenModelica/OpenModelica#5809):

- The path of omc was passed to START without quotes: Windows reported
  that it cannot find the part of the path before the space.
- system(cmd) did not return while omc was running, so the constructor
  never got to read the port file. omc is now started with the async
  type of system.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@adrpo
adrpo marked this pull request as ready for review November 18, 2026 08:35
adrpo added a commit to adrpo/OMMatlab that referenced this pull request Nov 18, 2026
The path of omc was passed to START without quotes. With an
installation in a directory with a space in its name, as the default
C:\Program Files\OpenModelica<version> has, Windows reports that it
cannot find the part of the path before the space
(OpenModelica/OpenModelica#5809). Found with the same command in
OMOctave (OpenModelica/OMOctave#5).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@adrpo
adrpo merged commit c552a44 into OpenModelica:master Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant