I was recently forced to update R to the latest version of 4.1.2 and since then my connection to db2 is not working. I use ibmdbR. I follow the steps as recommended by IBM: https://www.ibm.com/docs/en/db2-warehouse?topic=science-r-development-environment
it fails at step d, nitialising the analytics package by issuing the following R command. The ODBC connection works (or seems to be working) but idaInit(con) fails with the following error:
> idaInit(con) #this fails
Error in assign("idaRGlobal", new.env(parent = baseenv()), envir = baseenv()) :
cannot add binding of 'idaRGlobal' to the base environment
The con object is created without an issue:
> con <- idaConnect(con.text) # this is successful and con is created
I've tested my ODBC connection using online reference (below) and it's successful. https://www.ibm.com/docs/en/db2-warehouse?topic=programmatically-odbc-cli
More info on setup:
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ibmdbR_1.50.0 arules_1.7-2 Matrix_1.4-0 RODBC_1.3-19
loaded via a namespace (and not attached):
[1] magrittr_2.0.1 MASS_7.3-54 tidyselect_1.1.1 munsell_0.5.0 colorspace_2.0-2 lattice_0.20-45 R6_2.5.1 rlang_0.4.12 fansi_0.5.0 dplyr_1.0.7
[11] tools_4.1.2 parallel_4.1.2 grid_4.1.2 rpart.plot_3.1.0 gtable_0.3.0 utf8_1.2.2 ellipsis_0.3.2 tibble_3.1.6 lifecycle_1.0.1 crayon_1.4.2
[21] purrr_0.3.4 ggplot2_3.3.5 vctrs_0.3.8 rpart_4.1-15 glue_1.5.1 compiler_4.1.2 pillar_1.6.4 generics_0.1.1 scales_1.1.1 pkgconfig_2.0.3
It seems the error comes from executing this assignment in the code: assign("idaRGlobal", new.env(parent = baseenv()), envir=baseenv())
idaInit() code can be found here: rdrr.io/cran/ibmdbR/src/R/connection.R
I have completely removed R with all its libraries and installed everything from scratch, so I don't see how it could be a versioning issue. All packages seem to have the latest version. The only package that hasn't been updated after the release of R 4.2.1 are RODBC and IBMDBR.
Edit: Tried using RODBC directly and the connection works fine.