odbc
odbc copied to clipboard
on Mac M1: Can't open lib: '...' file not found
Issue Description and Expected Result
While trying to connect through FreeTDS
cdw <- DBI::dbConnect(
odbc(),
Driver="FreeTDS",
...)
I am running into an error:
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib '/opt/homebrew/Cellar/freetds/1.3.6/lib/libtdsodbc.0.so' : file not found
Which is obviously not true:
/opt/homebrew/Cellar/freetds/1.3.6/lib/libtdsodbc.0.so
-r--r--r-- 1 dlituiev admin 434K Jan 28 15:52 /opt/homebrew/Cellar/freetds/1.3.6/lib/libtdsodbc.0.so
This may be related to #474, which solved first step for me.
Database
MSSQL / connection issue
Reproducible Example
> odbc::odbcListDrivers()
name attribute value
1 FreeTDS Description FreeTDS Driver
2 FreeTDS Driver /opt/homebrew/Cellar/freetds/1.3.6/lib/libtdsodbc.0.so
3 FreeTDS UsageCount 1
4 ODBC Driver 17 for SQL Server Description Microsoft ODBC Driver 17 for SQL Server
5 ODBC Driver 17 for SQL Server Driver /opt/homebrew/lib/libmsodbcsql.17.dylib
6 ODBC Driver 17 for SQL Server UsageCount 1
Session Info
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.1.1 (2021-08-10)
os macOS Big Sur 11.5.1
system x86_64, darwin17.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Los_Angeles
date 2022-01-28
rstudio 2021.09.0+351 Ghost Orchid (desktop)
pandoc NA
─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
brio 1.1.3 2021-11-30 [1] CRAN (R 4.1.0)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.1.0)
callr 3.7.0 2021-04-20 [1] CRAN (R 4.1.0)
cli 3.1.0 2021-10-27 [1] CRAN (R 4.1.0)
crayon 1.4.2 2021-10-29 [1] CRAN (R 4.1.0)
desc 1.4.0 2021-09-28 [1] CRAN (R 4.1.0)
devtools * 2.4.3 2021-11-30 [1] CRAN (R 4.1.0)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0)
fs 1.5.0 2020-07-31 [1] CRAN (R 4.1.0)
glue 1.5.0 2021-11-07 [1] CRAN (R 4.1.0)
lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.0)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.1.0)
pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.1.0)
pkgload 1.2.4 2021-11-30 [1] CRAN (R 4.1.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.0)
processx 3.5.2 2021-04-30 [1] CRAN (R 4.1.0)
ps 1.6.0 2021-02-28 [1] CRAN (R 4.1.0)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.0)
remotes 2.4.2 2021-11-30 [1] CRAN (R 4.1.0)
rlang 0.4.12 2021-10-18 [1] CRAN (R 4.1.0)
rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.1.0)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.0)
testthat 3.1.2 2022-01-20 [1] CRAN (R 4.1.2)
usethis * 2.1.5 2021-12-09 [1] CRAN (R 4.1.0)
withr 2.4.3 2021-11-30 [1] CRAN (R 4.1.0)
[1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
@DSLituiev have you found a solution here?
Have an M1 Mac and running into the same error as you and others:
[unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found
@Worville did you figure it out? I am in the same situation as you are.
Seems similar to https://github.com/r-dbi/odbc/issues/501
From what I've seen so far, this error occurs when you have an architecture mismatch between R/RStudio and the ODBC library you have installed (i.e. x86_64 for R/RStudio, but aarch64 ODBC).
Based on your session info, it looks like you're running x86_64 R/RStudio, but based on your driver path /opt/homebrew/lib
it seems like you might have the aarch64 ODBC installed. If you'd like to leave your R/RStudio untouched, you can try installing the x86_64 version of ODBC to see if that resolves the issue.
I can confirm @sharon-wang s solution. I followed a procedure that Scott Brenstuhl has provided in this stackoverflow answer. I also wrote a short blog post about my quest to finding this solution:)