Repository navigation
Fail Modelica generation when paths.boblib is not the BobLib the builds load - #152
Merged
Merged
Conversation
A stale paths.boblib (for example lhre's old-layout value _0_Utils/external/BobLib/BobLib) made the generator create a stray record tree and report success. The build then compiled the untouched engines/boblib records, so the executed car was not the YAML car. The planner now requires paths.boblib to name a directory whose package.mo declares package BobLib. It raises BobLibRootError before any write. The error names the path, the resolution base and the fix. generate_modelica_stack also refuses to write a file that resolves outside that package root. The CLI prints the error and exits 2. Test fixtures that wrote into a bare tmp BobLib directory now create a minimal package.mo.
The previous guard accepted any directory whose package.mo declared package BobLib. An in-place submodule update from the old layout can leave the old _0_Utils/external/BobLib/BobLib tree on disk. A vehicle file that still named it passed the guard. The generator wrote records into that tree and reported success. The builds load only engines/boblib/BobLib (build_vehicle_sim.mos and build_four_post_sim.mos line 4), so they compiled the untouched records. The planner now requires paths.boblib to resolve to <root>/engines/boblib/BobLib. It also requires that package.mo exists. Otherwise it raises BobLibRootError before any write. The error names both paths. A test checks that both .mos files load the same directory as the generator constant, so the two cannot drift. Test fixtures now place their BobLib package at engines/boblib/BobLib.
_run_modelica_build_action caught every exception from the stack status call, logged "Build cache unavailable" and compiled fresh. A BobLibRootError therefore did not stop the app build. The build then compiled records that did not come from the vehicle file. The action now catches BobLibRootError first. It logs the error and returns 1 without starting OpenModelica. Other status errors keep the fresh-compile fallback.
rhorvath02
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A stale
paths.boblibmade the generator write a stray record tree and report success. The builds load onlyengines/boblib/BobLib(line 4 ofbuild_vehicle_sim.mosandbuild_four_post_sim.mos), so the executed car was not the YAML car. The app build also caught the error and compiled anyway.Changes
paths.boblibto resolve to<root>/engines/boblib/BobLibwith apackage.mo. Otherwise it raisesBobLibRootErrorbefore any write. The CLI exits 2.How to check
New tests in
tests/test_modelica_generator.pyandtests/test_app_shell.py, including one that checks both.mosfiles load the generator's directory. Full suite at the top of the stack: 1150 passed, 39 skipped, 1 worktree-only failure (test_bobsim_sources_do_not_reference_legacy_boblib_generation_layout,git ls-filesin a worktree).Notes
Stack
1 of 7. Based on
main.Overlap
#151 edits the same import block and one test in
tests/test_modelica_generator.py. The conflict is trivial: keep both.