﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6078	OPENMODELICALIBRARY and MODELICAPATH ignored?	john.pye@…	Martin Sjölund	"Hi there,

With SolarTherm (https://github.com/SolarTherm/SolarTherm), we execute 'omc' directly to compile our models, and then we invoke the model executable ('C runtime') to run our simulations.

We use CMake to install our model library in a user-selectable file location, and rely on the ability to set OPENMODELICALIBRARY environment variable to point correctly at the location of our bespoke model library.  Normally we install our files to ~/.local/lib/omlibrary/SolarTherm, for example.

With OM 1.14 and also (I believe) 1.15, this worked fine, and 'omc' would correctly find our models and simulation could proceed.

However in OM 1.16, we have found that 'omc' doesn't find the model files, and gives us an error about failing to load the package and advising us of the current value of MODELICAPATH:

{{{
<env>john@thunder:~/solartherm/examples$ st_simulate --np 0  SimpleSystem.mo 
Compiling model
Error processing file: /home/john/solartherm/examples/SimpleSystem.mo
Failed to load library: SolarTherm!

Notification: Automatically loaded package Complex 3.2.3 due to uses annotation.
Notification: Automatically loaded package ModelicaServices 3.2.3 due to uses annotation.
Notification: You can install the requested package using one of the commands:
  installPackage(SolarTherm, ""0.2.0-master"", exactMatch=true)
  installPackage(SolarTherm).
Error: Failed to load package SolarTherm (default) using MODELICAPATH /usr/bin/../lib/omlibrary:/home/john/.openmodelica/libraries/.

# Error encountered! Exiting...
# Please check the error message and the flags.
Failed to load library: SolarTherm!

Execution failed!
Traceback (most recent call last):
  File ""/home/john/.local/bin/st_simulate"", line 138, in <module>
    sim.compile_model(args=mcargs)
  File ""/home/john/.local/lib/python2.7/site-packages/solartherm/simulation.py"", line 276, in compile_model
    + libs)
  File ""/usr/lib/python2.7/subprocess.py"", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['omc', '-s', '-q', '-n=0', '-i=SimpleSystem', '/home/john/solartherm/examples/SimpleSystem.mo', 'Modelica', 'SolarTherm']' returned non-zero exit status 1
<env>john@thunder:~/solartherm/examples$ 
}}}

I note that we have the OPENMODELICALIBRARY environment variable set as earlier advised:

{{{
<env>john@thunder:~/solartherm/examples$ env|grep MODELICA
_OPENMODELICALIBRARY=
OPENMODELICALIBRARY=/home/john/.openmodelica/libraries:/home/john/.local/lib/omlibrary:/usr/lib/omlibrary:/usr/local/lib/omlibrary
}}}

I note that if I set MODELICAPATH to equal our above value of OPENMODELICALIBRARY:

{{{
<env>john@thunder:~/solartherm/examples$ export MODELICAPATH=$OPENMODELICALIBRARY
}}}

THEN, it *still* doesn't work; I get the same error:

{{{
<env>john@thunder:~/solartherm/examples$ st_simulate --np 0  SimpleSystem.mo 
Compiling model
Error processing file: /home/john/solartherm/examples/SimpleSystem.mo
Failed to load library: SolarTherm!

Notification: Automatically loaded package Complex 3.2.3 due to uses annotation.
Notification: Automatically loaded package ModelicaServices 3.2.3 due to uses annotation.
Notification: You can install the requested package using one of the commands:
  installPackage(SolarTherm, ""0.2.0-master"", exactMatch=true)
  installPackage(SolarTherm).
Error: Failed to load package SolarTherm (default) using MODELICAPATH /usr/bin/../lib/omlibrary:/home/john/.openmodelica/libraries/.
[...]
}}}

And to double check, 

{{{
<env>john@thunder:~/solartherm/examples$ env|grep MODELICA
MODELICAPATH=/home/john/.openmodelica/libraries:/home/john/.local/lib/omlibrary:/usr/lib/omlibrary:/usr/local/lib/omlibrary
_OPENMODELICALIBRARY=
OPENMODELICALIBRARY=/home/john/.openmodelica/libraries:/home/john/.local/lib/omlibrary:/usr/lib/omlibrary:/usr/local/lib/omlibrary
}}}

So it seems that whatever support previously existed for using environment variables to control 'omc' has become broken, and it seems that the error message being provided by OMC is inaccurate, since even setting MODELICAPATH doesn't seem to work.

Any thoughts?

Cheers
JP"	defect	assigned	high		*unknown*	v1.16.0-dev			Francesco Casella
