Skip to content

Make cmdstan_version_compare() refuse a missing version - #1284

Merged
jgabry merged 2 commits into
v1.0from
fix-version-compare
Sep 23, 2026
Merged

jgabry merged 2 commits into
v1.0from
fix-version-compare

Conversation

@jgabry

@jgabry jgabry commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Submission Checklist

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

Summary

I had Claude generate the summary below

cmdstan_version_compare() returned -1 for an empty or NA first
argument and 1 for an empty second one, standing in for "no install
found" during path discovery. That is the same -1 an older version
gets, so a caller could not tell the two apart.

Both arguments must now be non-empty strings. Dropping the guards alone
would not have been enough, since utils::compareVersion("", "2.35.0")
also returns -1. The callers that can meet a missing version handle it
on their own side:

  • cmdstan_default_path() picks the install that exists before
    comparing, so it only compares when both a native and a WSL install
    were found.
  • The startup check in .onAttach() wraps the whole comparison in
    try(), so a failed download, no CmdStan, or a bad version all skip
    the "newer version available" message.
  • is_supported_cmdstan_version() already mapped an error to FALSE.

$sample() compares the model's version, which on v1.0 always comes
from a validated build record or the executable's info output, so it
does not need a guard.

Closes #1260

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:

It returned -1 for an empty or NA first argument and 1 for an empty
second one, standing in for "no install found" during path discovery.
That is the same -1 an older version gets, so a caller could not tell
the two apart. Both arguments must now be non-empty strings, since
utils::compareVersion() itself treats "" as older. cmdstan_default_path()
handles a missing native or WSL install before comparing, and the
startup check wraps the whole comparison in try().

Closes #1260.
@jgabry
jgabry changed the base branch from master to v1.0 September 23, 2026 16:13
@jgabry jgabry linked an issue Sep 23, 2026 that may be closed by this pull request
The notes still described cmdstan_version_compare() as returning -1 for
a missing version and the install-path code as relying on that. Both
are false since the comparison started refusing a missing version, so
the passage now records the old behavior as the removed instance of the
tri-state collapse and says where the callers handle a missing version
instead. The contract file did not change because the passage sits
outside the contract markers.

Part of #1260.
@codecov-commenter

codecov-commenter commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v1.0@90db219). Learn more about missing BASE report.

Files with missing lines Patch % Lines
R/path.R 42.85% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             v1.0    #1284   +/-   ##
=======================================
  Coverage        ?   93.10%           
=======================================
  Files           ?       19           
  Lines           ?     7320           
  Branches        ?        0           
=======================================
  Hits            ?     6815           
  Misses          ?      505           
  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.

@jgabry
jgabry marked this pull request as ready for review September 23, 2026 20:05
@jgabry
jgabry merged commit 58de6db into v1.0 Sep 23, 2026
15 checks passed
@jgabry
jgabry deleted the fix-version-compare branch September 23, 2026 20:05
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.

cmdstan_version_compare() conflates no version with old version

2 participants