rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
606 stars 190 forks source link

Can not run bundle install arm64 #492

Closed DonikaV closed 8 months ago

DonikaV commented 3 years ago

After i run bundle install i am getting this errors.

Fetching tiny_tds 2.1.2
Installing tiny_tds 2.1.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/valeriidonika/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/tiny_tds-2.1.2/ext/tiny_tds
/Users/valeriidonika/.rbenv/versions/2.7.2/bin/ruby -I /Users/valeriidonika/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20210416-64091-1vlr042.rb extconf.rb
checking for sybfront.h... no
checking for sybdb.h... no
checking for tdsdbopen() in -lsybdb... no
checking for dbanydatecrack() in -lsybdb... no
Failed! Do you have FreeTDS 0.95.80 or higher installed?
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/valeriidonika/.rbenv/versions/2.7.2/bin/$(RUBY_BASE_NAME)
    --help
    --with-freetds-dir
    --without-freetds-dir
    --with-freetds-include
    --without-freetds-include=${freetds-dir}/include
    --with-freetds-lib
    --without-freetds-lib=${freetds-dir}/lib
    --with-sybdb-dir
    --without-sybdb-dir
    --with-sybdb-include
    --without-sybdb-include=${sybdb-dir}/include
    --with-sybdb-lib
    --without-sybdb-lib=${sybdb-dir}/lib
    --with-sybdblib
    --without-sybdblib
    --with-sybdblib
    --without-sybdblib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/valeriidonika/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/tiny_tds-2.1.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/valeriidonika/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/tiny_tds-2.1.2 for inspection.
Results logged to /Users/valeriidonika/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/tiny_tds-2.1.2/gem_make.out

An error occurred while installing tiny_tds (2.1.2), and Bundler cannot continue.
Make sure that `gem install tiny_tds -v '2.1.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  activerecord-sqlserver-adapter was resolved to 5.2.1, which depends on
    tiny_tds

FreeTDS is installed by homebrew

brew link freetds                                                                                                    
Warning: Already linked: /opt/homebrew/Cellar/freetds/1.2.20
To relink:
  brew unlink freetds && brew link freetds

Tried with this command gem install tiny_tds -- --with-freetds-include=/opt/homebrew/include --with-freetds-lib=/opt/homebrew/lib

Same issues.

This is in the logs

ld: warning: directory not found for option '-L/usr/local/lib/freetds'
ld: library not found for -lsybdb
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
Charlie-Hua commented 3 years ago

got it work with BUNDLE_BUILD__TINY_TDS="--with-freetds-include=/opt/homebrew/include --with-freetds-lib=/opt/homebrew/lib" bin/bundle install

thomasklemm commented 3 years ago

For me this worked on MacBook Air (M1, 2020), macOS Big Sur 11.4, Ruby 3.0.1:

$ brew install freetds
$ gem install tiny_tds -- --with-freetds-include=/opt/homebrew/include --with-freetds-lib=/opt/homebrew/lib
e4r7hbug commented 1 year ago

This bundler configuration from https://github.com/rails-sqlserver/tiny_tds/issues/484#issuecomment-1208559626 worked for me:

bundle config build.tiny_tds --with-freetds-include=/opt/homebrew/include --with-freetds-lib=/opt/homebrew/lib
andyundso commented 8 months ago

Fix has been merged with #545 (original PR: #531) and was released with 2.1.6. It should no longer be necessary to pass --with-freetds-include or --with-freetds-lib on Macs with Apple Silicon.