Skip to content

Launch the model executable with the TBB it was built against - #1281

Merged
jgabry merged 5 commits into
v1.0from
tbb-launch-dir
Sep 22, 2026
Merged

jgabry merged 5 commits into
v1.0from
tbb-launch-dir

Conversation

@jgabry

@jgabry jgabry commented Sep 22, 2026

Copy link
Copy Markdown
Member

Submission Checklist

  • Run unit tests
  • Declare copyright holder and agree to license (see below)

Summary

This PR and the summary below were made with the assistance of AI. I have reviewed all code and doc.


Closes #1261. Part of #1258.

On Windows the executable finds tbb.dll through PATH, and every launch put
the selected installation's lib/tbb there. That is the wrong TBB as soon
as the selected installation is not the one that built the model: build
with 2.39, set_cmdstan_path() to 2.40, sample, and the 2.39 binary runs
against 2.40's TBB. The build record already says which directory the
build linked against (tbb_dir), and nothing read it.

Now the four sites that launch the model executable (the chains, diagnose,
$cmdstan_defaults() and the post-build info call) put the recorded
directory on PATH. If that directory is gone nothing is added, so the
executable runs with whatever TBB is already on PATH or fails to load, but
it is never pointed at a different installation's TBB. Without a usable
record the selected installation's directory is used as before. The
installation programs (make, stanc, stansummary) are untouched.

When a launch fails and the recorded directory is gone, the error from
#1280 says so and adds reinstalling it as a remedy:

The executable at 'C:/models/bernoulli.exe' could not be run: exit status -1073741515
The TBB it was built against at 'C:/cmdstan-2.39.0/stan/lib/stan_math/lib/tbb' no longer exists.
Reinstall it there or run cmdstan_model() with force_recompile = TRUE to rebuild it.

This also removes the Windows skip added to the adoption test in #1280:
that test deselects the installation, which is exactly the case the record
now covers.

The second commit replaces two tests that mocked os_is_windows() and
os_is_wsl() with tests that check whichever branch the platform takes,
since the Windows and WSL jobs run the other branches for real. The third
renames run_info_cli() to run_exe_info(), since what it runs is the
executable's own info command.

Copyright and Licensing

Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Jonah Gabry

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses:

On Windows the executable finds tbb.dll through PATH, and every launch
put the selected installation's lib/tbb there, which is the wrong TBB
once a different installation is selected. The four sites that launch
the model executable now use the directory the build record holds. If
that directory is gone nothing is added, so the executable is never
pointed at another installation's TBB. Without a usable record the
selected installation's is used as before. When a launch fails and the
recorded directory is gone, the error says so and adds reinstalling it
as a remedy.

The Windows skip added to the adoption test in #1280 is removed, since
that is the case the record now covers.

Closes #1261. Part of #1258.
The TBB launch helper's Windows branch and the WSLENV assembly were
tested everywhere by mocking os_is_windows() and os_is_wsl(). The
Windows and WSL CI jobs run those branches for real, so the tests now
check whichever branch the platform takes.
What it runs is the executable's own info command, and the new name
reads naturally beside reported_features_from_exe().
@jgabry jgabry linked an issue Sep 22, 2026 that may be closed by this pull request
4 tasks
@codecov-commenter

codecov-commenter commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.41270% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v1.0@76aaede). Learn more about missing BASE report.

Files with missing lines Patch % Lines
R/model.R 93.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             v1.0    #1281   +/-   ##
=======================================
  Coverage        ?   93.42%           
=======================================
  Files           ?       19           
  Lines           ?     7312           
  Branches        ?        0           
=======================================
  Hits            ?     6831           
  Misses          ?      481           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A TBB_LIB or TBB_BIN value like "$(MATH)lib/tbb" was recorded as written,
so the record named a directory that never existed and, on Windows, the
launch put nothing on PATH. Rebuilding recorded the same thing again, so
the launch error's remedy didn't help. cmdstan_model() now rejects such a
value before the build and asks for a literal directory. Also softens the
stop_cannot_run() roxygen, since a gone TBB is one likely cause of a
failed launch rather than the likely one.

Part of #1258.
The check for a make expression looked only at character values, so a
factor or a list carrying one still reached make as the expression.
Checking the assignment strings the options turn into covers every type
the same way and drops the type guard.
@jgabry
jgabry marked this pull request as ready for review September 22, 2026 21:29
@jgabry
jgabry merged commit b321829 into v1.0 Sep 22, 2026
15 checks passed
@jgabry
jgabry deleted the tbb-launch-dir branch September 22, 2026 21:29
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.

Launch the model executable with the TBB its build resolved

2 participants