Fwd: [nmatzke/BioGeoBEARS] fix(optimx): Fix version checking for optimx (PR #14)

34 views
Skip to first unread message

Nick Matzke

unread,
May 8, 2024, 7:20:23 PM5/8/24
to bioge...@googlegroups.com
Hi all,

Some intrepid users figured out a bug that was occurring.  I was able to replicate it when I upgraded to the new version of R, 4.4.0.

If you get an error like this:

Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) :
  invalid non-character version specification 'x' (type: double)

...it comes from parts of the code that are checking package versions, e.g.:

packageVersion("optimx") < 2017

Something in the new R makes this error, I think perhaps they added the class "numeric_version" to the "package_version" class:

class(packageVersion("optimx"))
# "package_version" "numeric_version"

Anyway, it works when I change it to 

packageVersion("optimx") < "2017"

...so I have made that change throughout the BioGeoBEARS code. Update from GitHub to get the new version, especially if you have upgraded to R 4.4.0.

library(devtools)
devtools::install_github(repo="nmatzke/BioGeoBEARS")

Cheers, and thanks for the pull request!
Cheers,
Nick



---------- Forwarded message ---------
From: computations <notifi...@github.com>
Date: Fri, Apr 26, 2024 at 9:14 PM
Subject: [nmatzke/BioGeoBEARS] fix(optimx): Fix version checking for optimx (PR #14)
To: nmatzke/BioGeoBEARS <BioGe...@noreply.github.com>
Cc: Subscribed <subsc...@noreply.github.com>


It appears the behavior for the line

  if(packageVersion("optimx") == 2017)

has changed such that the right hand side is coerced into a version string via (after some other calls) make_numeric_version, which only accepts character strings. The constant 2017 is interpreted as a double, which causes the function fail, which halts the script. The solution is simply to turn the numeric constants to string constants in this context.

Additionally, I replaced a unicode dash with an ascii dash, as it was causing problems when sourcing the script.


You can view, comment on, or merge this pull request online at:

  https://github.com/nmatzke/BioGeoBEARS/pull/14

Commit Summary

  • d32f78c fix(optimx): Fix version checking for optimx

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <nmatzke/BioGeoBEARS/pull/14@github.com>

Reply all
Reply to author
Forward
0 new messages