How do I install the ODBC driver for Snowflake successfully on an M1 Apple Silicon Mac?
Asked Answered
G

6

5

I'm having issues getting the ODBC driver for Snowflake to work on an M1 Apple Silicon Mac running Big Sur.

Successfully following the instructions on Snowflake's website gets me to the point where testing the driver from the command line (using iodbctest) using the DSN results in the following error:

1: SQLDriverConnect = [iODBC][Driver Manager]dlopen(/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib, 6): no suitable image found.  Did find:
    /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib: no matching architecture in universal wrapper
    /opt/snowfl (0) SQLSTATE=00000
2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003

My Snowflake driver is installed to /opt/snowflake/snowflakeodbc, so that is correct -- I'm suspicious that this is specifically an M1 problem. I'm using the 2.24.1 version of the driver available from the download mirror here, and the path to the driver in /etc/odbcinst.ini is /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib (which exists and seems, from all my research, that it should be right).

When I run a connection via DBI in R, I get a completely different error:

 Error: nanodbc/nanodbc.cpp:1021: 00000: 
[Snowflake][ODBC] (11560) Unable to locate SQLGetPrivateProfileString function. 

In other StackOverflow posts, people have referenced the above error meaning that there is a missing library of some kind (IODBC isn't configured correctly?), but I've tried quite a few things to no avail. Any guidance would be great.

Godthaab answered 21/9, 2021 at 20:25 Comment(2)
Not yet supported, but soon 🤞Baby
Hi did you find any solution for this problem.Sutherlan
G
6

Tinkered with this a bit more and realized it's an artifact of the installation pathways for the .dmgs & the preset paths in simba.snowflake.ini.

You need to point the Snowflake driver towards the iODBC dylib (as per a sideswiping statement in the docs) -- the driver is originally configured to look for the ODBC dylib (not iODBC) in a folder that's on the path.

When you install the iODBC driver, verify that it is installed to /usr/local/iODBC (this was where my Silicon Mac installed it to) -- and that /usr/local/iODBC/lib has libiodbc.dylib in it. If so, navigate to your installed snowflake driver directory (should be /etc/snowflake) and alter the simba.snowflake.ini file (/etc/snowflake/snowflake/snowflakeodbc/universal/simba.snowflake.ini). You want to uncomment & alter the last line to be both uncommented & point with a full path towards the iODBC dylib (instead of the default, which is the ODBC dylib).

# Darwin specific ODBCInstLib
#   iODBC
ODBCInstLib=/usr/local/iODBC/lib/libiodbcinst.dylib

Make sure to comment out any other ODBCInstLib line so that only one is configured. That should enable you to get your connection to snowflake up and running on an M1 Mac.

Godthaab answered 22/9, 2021 at 10:42 Comment(5)
But bear in mind that this is not a supported configuration so implementing this would be at the user’s risk.Drear
@Drear I was taking this as a mistake in the config file, since you're only changing the simba.snowflake.ini file to point to iODBC (which....confusingly, is what the file annotates the filepath as, even though it points to the ODBC install instead). But good flag regardlessGodthaab
Thanks for this answer but there's no Snowflake driver directory at /etc/snowflake/.... As per the documentation Snowflake is installed to /opt/snowflake/snowflakeodbc and /Library/ODBCOpulence
@Opulence In that case, you can find the simba.snowflake.ini file in /opt/snowflake/snowflakeodbc/lib/universalWillson
This worked perfectly (minor different paths aside). Just adding that to fix some encoding errors causing malformed responses from odbc, I had to reinstall odbc after installing iODBC. Look out for Found iodbc-config cflags and libs! in the install messages to check it is compiling correctly.Execration
P
5

None of the other solutions worked for me but @kiran-kumawat 's answer set me down a path that worked.

It seems like the core of the issue is that the odbc code is looking for arm64 architecture drivers but Snowflake is providing it in x86_64 architecture. By installing an x86_64 versions of odbc we are able to have it successfully talk to the driver.

First I uninstalled R and Rstudio. (it may be possible to sim-link or change things behind the scenes to make this work with existing installs but I am not sure).

Then install rosetta (apples software for translating between architectures) and a version of homebrew built with it. I am leaving my main version of homebrew in place.

softwareupdate --install-rosetta
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Then use that version of homebrew to install odbc, R, and Rstudio.

arch -x86_64 /usr/local/Homebrew/bin/brew install unixodbc
arch -x86_64 /usr/local/Homebrew/bin/brew install --cask rstudio
arch -x86_64 /usr/local/Homebrew/bin/brew install --cask r

We then need to install the snowflake driver: https://sfc-repo.snowflakecomputing.com/odbc/mac64/latest/index.html

Click through all the install prompts.

Modify your files

/usr/local/etc/odbcinst.ini:

[Snowflake Driver]
Driver          = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib

/usr/local/etc/odbc.ini

[Snowflake]
Driver             = Snowflake Driver
uid                = <uid>
server             = <server>
role               = <role>
warehouse          = <warehouse>
authenticator      = externalbrowser

We also need to modify the simba.snowflake.ini file.

It is somewhat locked down so run:

sudo chmod 646 /opt/snowflake/snowflakeodbc/lib/universal/simba.snowflake.ini

Then

vim /opt/snowflake/snowflakeodbc/lib/universal/simba.snowflake.ini

And find the ODBCInstLib line that is uncommented and change it to:

ODBCInstLib=/usr/local/Cellar/unixodbc/2.3.9_1/lib/libodbcinst.dylib

After setting this up I was able to use this connection successfully:

install.packages("DBI")
install.packages("odbc")
con <- DBI::dbConnect(odbc::odbc(), "Snowflake")
Psychodiagnostics answered 8/4, 2022 at 0:41 Comment(0)
D
3

Big Sur is macOS v11.n

Snowflake supports macOS 10.14 and 10.15 Supported OSs

So what you are trying to do is not supported and is unlikely to work

Drear answered 21/9, 2021 at 20:50 Comment(0)
S
1

one of our team member suggested below steps and it worked for us for Apple M1 series

  1. Install the latest snowflake driver

  2. Uninstall m1 based homebrew using cmd /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

  3. Install intel based homebrew - restart terminal when done arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

  4. Re-install unixodbc arch -x86_64 brew install unixodbc

  5. Test isql -v Pattern

  6. in your database.yml file for connection to snowflake make following change- replace "dsn: <DSN_NAME>" with following conn_str: "Driver={PATH};Locale=en-US;uid={USER_NAME};pwd= {PASSWORD};server=<yours>.snowflakecomputing.com;role=<ROLE>;charset=UTF-8;warehouse=<WAREHOUSE>;database=<DATABASE>;schema=<SCHEMA>;"

Sutherlan answered 4/2, 2022 at 7:57 Comment(0)
J
0

Has anyone gotten this to work? I use excel w odbc to refresh snowflake files and have tried multiple ways to move the drivers etc and followed snowflake instructions but never works. I did get parallels to work running windows arm but would prefer to just do this in Mac OS

Johnette answered 30/1, 2022 at 21:25 Comment(1)
Did you not check the link? It’s still not supportedDrear
M
0

I also have a M1 (version Monterey 12.0) and I ran into similar issues when I tested the driver. Nevertheless, when I tried the "real connection" it worked like a charm. So, maybe it would be good for you to go and test the "real connection" to avoid a wasting of time using such testing. Hope you find this useful.

Matejka answered 30/3, 2022 at 15:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.