[R-SIG-Mac] Can't make odbc FreeTDS connections in R.app, can with RStudio, /usr/local/bin/R, Rscript
jpre|d @end|ng |rom m@c@com
Wed Aug 11 19:31:35 CEST 2021
I’m experiencing some weirdness with database connections using R 4.1 on macOS 11.5.1 and the `odbc` package with the FreeTDS driver. I can replicate the problem on my coworker’s Mac with R 4.0 (macOS 11, not sure which version).
Running this code works fine on the command line (or with RStudio, /usr/local/bin/R), /usr/local/bin/Rscript -e “library(odbc); con = dbConnect(odbc(), 'GISLibrary'); dbGetQuery(con, ‘select 1 num’); dbDisconnect(con)”
But the connection fails with the exact same code in R.app (I’ve tried R.app rev 7976 and 7982). I often get a segfault, like "address 0x7f975f481cb0, cause 'memory not mapped’”. The connection works fine with the ODBC Driver 17 for SQL Server in all execution environments.
The connection also fails in some environments (rmarkdown::render, Rscript -e) if I load the package sf before making the first connection attempt, e.g., Rscript -e "library(odbc); library(sf); con = dbConnect(odbc(), 'GISLibrary'); dbGetQuery(con, 'select 1 num'); dbDisconnect(con);". If I delay loading sf until after I’ve successfully made a connection with the FreeTDS driver I can continue to make connections.
I saw the recent post about breaking ABI changes in the Rcpp package, so I followed the instructions to re-install all packages that depend on Rcpp. That did not solve the problem.
More information about the R-SIG-Mac