library(arm) fails to load with the following error:
Warning in packageDescription("arm", lib.loc = mylib): no package 'arm' was found
Error: package or namespace load failed for 'arm':
.onAttach failed in attachNamespace() for 'arm', details:
call: packageDescription("arm", lib.loc = mylib)$Version
error: $ operator is invalid for atomic vectors
The .onAttach function uses a variable mylib which is hardcoded at build time. When the package is loaded on a machine running a different R version than the one it was built on, packageDescription("arm", lib.loc = mylib) cannot find the package and returns NA instead of a list. Calling $Version on NA then crashes with the above error.
Environment:
- R version: 4.5.1
- arm version: 1.15-3 (built under R 4.5.3)
- OS: Windows Server 2022 x64
Suggested Fix:
Add a null/NA check in .onAttach before calling $Version:
desc <- packageDescription("arm", lib.loc = mylib)
if (!is.list(desc)) desc <- packageDescription("arm")
if (is.list(desc)) packageStartupMessage(paste("arm (Version", desc$Version, "built:", desc$Date))
library(arm)fails to load with the following error:The
.onAttachfunction uses a variablemylibwhich is hardcoded at build time. When the package is loaded on a machine running a different R version than the one it was built on,packageDescription("arm", lib.loc = mylib)cannot find the package and returnsNAinstead of a list. Calling$VersiononNAthen crashes with the above error.Environment:
Suggested Fix:
Add a null/NA check in
.onAttachbefore calling$Version: