pepsico-ecommerce / snowflex

elixir snowflake client
Apache License 2.0
52 stars 10 forks source link

Apple M1 Support #39

Closed sescobb27 closed 2 years ago

sescobb27 commented 2 years ago

Hi there, sorry to ask here, but have you been able to run the project with apple M1? i have been trying to do it, but no success so far, i always get the following errors, i tried to do the same on apple intel and worked, but i may be doing something wrong on M1 and that's why i'm asking, thank you.

[warning] Unable to connect to snowflake: [unixODBC][Driver Manager]Can't open lib '/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib' : file not found SQLSTATE IS: 01000 Connection to database failed.
snowflake Driver's SQLAllocHandle on SQL_HANDLE_HENV
# ~/Library/ODBC/odbc.ini

[ODBC Data Sources]
SnowflakeDSII = Snowflake

[SnowflakeDSII]
Server = xxx.snowflakecomputing.com
UID = xxx
Schema = PUBLIC
Warehouse = xxx
Role = xxx
Database = xxx
Driver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
Description = Snowflake DSII
Locale = en-US
Tracing = 0
# ~/Library/ODBC/odbcinst.ini

[ODBC]
Trace=no
TraceFile=

[ODBC Drivers]
Snowflake                       = Installed

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

ODBCInstLib=/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
# config.exs
config :snowflex, driver: "/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib"

config :job_api, JobApi.SnowflakeConnection,
  connection: [
    role: "xxx",
    warehouse: "xxx",
    uid: "xxx",
    pwd: "xxx",
    server: "xxx.snowflakecomputing.com",
    schema: "PUBLIC",
    database: "xxx"
  ]
mphfish commented 2 years ago

Hey @sescobb27, thanks for opening an issue!

~This has been a problem for us as well as more engineers get issued Apple Silicon Macbooks. Some of us have had success with installing the entire Elixir toolchain via Rosetta, but the real solution is that we need Snowflake to deploy an ODBC driver for Apple Silicon.~

Looks like Chase has much more up to date info than I! Definitely check out his recommendations @sescobb27 .

Ch4s3 commented 2 years ago

I believe some folks are successfully using the new driver here https://sfc-repo.snowflakecomputing.com/odbc/macaarch64/index.html

Ch4s3 commented 2 years ago

We're going to work on this.

sescobb27 commented 2 years ago

hey there, i was able to solve with that installation and some other configs, i had to clear everything i did and configure it again, here is my setup if you or someone else is interested:

brew install unixodbc
# we are using 2.3.11
sudo ln -s /opt/homebrew/Cellar/unixodbc/2.3.11/ /usr/local/odbc
# add compile flag to erlang via ~/.kerlrc
KERL_CONFIGURE_OPTIONS="--with-odbc=/opt/homebrew/Cellar/unixodbc/2.3.11"
GREP_OPTIONS=''
export CC="/usr/bin/gcc -I/opt/homebrew/Cellar/unixodbc/2.3.11/include"
export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.11/lib"
asdf install erlang 24.3.4

# add the following to /opt/snowflake/snowflakeodbc/lib/simba.snowflake.ini
ODBCInstLib=/opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbcinst.dylib

# elixir config
config :snowflex, driver: "/opt/snowflake/snowflakeodbc/lib/libSnowflake.dylib"
PM-Pepsico commented 2 years ago

Thanks for posting this! I was able to build for Apple Silicon by following something similar.

However adding the KERL_CONFIGURE_OPTIONS to ~/.kerlrc doesn't seem to be necessary as it does not get read by asdf (https://github.com/asdf-vm/asdf-erlang/issues/181). Symlinking to usr/local/odbc is enough on its own, as that is the default directory Erlang will search for odbc when compiling.