Skip to content

Conversation

@MichaelChirico
Copy link

@MichaelChirico MichaelChirico commented Oct 9, 2025

https://stat.ethz.ch/R-manual/R-devel/library/utils/html/sessionInfo.html

I see this used in a few places -- checking in first before applying it elsewhere that this is something you find useful / the preferred approach for addressing it:

https://github.com/search?q=repo%3Afutureverse%2Ffuture.batchtools%20%2FosVersion%2F&type=code

@HenrikBengtsson
Copy link
Collaborator

HenrikBengtsson commented Oct 10, 2025

Hi, thanks for spotting this - I didn't know about the NULL. Sounds like a feature request to R return NA_character_ instead of NULL.

Here's my train of though. My inner OCD says:

osVersion = if (is.null(utils::osVersion)) NA else utils::osVersion,

should be

osVersion = if (is.null(utils::osVersion)) NA_character_ else utils::osVersion,

My non-inner OCD says: "NA is okay, it's just an example". But what about:

osVersion = if (is.null(utils::osVersion)) "?" else utils::osVersion,

or just

osVersion = if (is.null(utils::osVersion)) "" else utils::osVersion,

? Now, that's a mouth full. What about:

osVersion = utils::osVersion %||% "?"

Hmm, that requires R (>= 4.4.0), but we tend to have academic HPC users running on old versions of R. Argh... Think think think, "it's just an example" and NULL is only on "bizarre platforms" so very unlikely there a user who will actually run into this. So, what about:

osVersion = paste0(utils::osVersion, "")

? That'll give an empty string in those cases, but no-one will complain.

@MichaelChirico
Copy link
Author

Yea, on second thought, maybe it's best to just let this go? Even the paste0() thing will make the example less readable.

The one place I actually encountered this was a testing environment -- only robots are running examples there. And even then it may have just been transient, I wasn't able to reproduce it now, maybe a kernel/OS/policy update got it working again.

Some alternatives that can still scratch our itch to be "correct":

  • Make these @examplesIf !is.null(utils::osVersion) to avoid a cryptic error and just skip the examples
  • Use \dontshow{ if (is.null(utils::osVersion)) stop("These examples should be run in a 'normal' environment with utils::osVersion populated.") }

Sounds like a feature request to R return NA_character_ instead of NULL.

Agree NA_character_ seems a way more natural return value than NULL

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.

2 participants