tiny_tds icon indicating copy to clipboard operation
tiny_tds copied to clipboard

Environment variable

Open sterankin opened this issue 6 years ago • 2 comments

I am using the environment variable (FREETDS_DIR) to provide a path to freetds in my application.

Since I am using Cloud Foundry and can only use 1 buildpack, I need to vendor the freetds dependency (please see the custom libraries section here: https://docs.pivotal.io/pivotalcf/2-2/buildpacks/ruby/ruby-tips.html#custom-libraries)

I am unclear what I need to do in order to provide the freetds dependencies that tiny_tds needs. Do I need to build and compile freetds or simply download the zip file and unzip it?

Here is what I have done:

  • cloned freetds-master on my local mac
  • followed the instructions here: https://github.com/FreeTDS/freetds/blob/master/INSTALL.GIT.md
  • I haven't done a Make Install, just a Make.
  • next steps?

Is this sufficient, from looking at the tiny_tds code, it looks for a freetds/include folder and also a freetds/lib folder.

I don't see a lib folder anywhere.

Can I vendor the freetds dependency this way and what folders should I supply with my applications source code?

Thanks

sterankin avatar Jun 10 '19 18:06 sterankin

Just to add an update, I am now trying to use the bundler config option, which allows you to tell bundler where to install the freetds libraries from.

So my bundle/.config file looks like:

---
BUNDLE_BUILD__TINY_TDS: "--with-freetds-dir=/home/vcap/app/ld_library_path/freetds"

From the logs I can see bundler using this option when installing tiny_tds, although it seems to have an extra backslash before the = sign?

--with-freetds-dir\=/home/vcap/app/ld_library_path/freetds

Full log:

current directory:
          /tmp/contents075463777/deps/0/vendor_bundle/ruby/2.4.0/gems/tiny_tds-2.1.2/ext/tiny_tds
          /tmp/contents075463777/deps/0/ruby/bin/ruby -I
          /tmp/contents075463777/deps/0/ruby/lib/ruby/site_ruby/2.4.0 -r
          ./siteconf20190611-51-sl5mbj.rb extconf.rb
          --with-freetds-dir\=/home/vcap/app/ld_library_path/freetds
          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=/tmp/contents075463777/deps/0/ruby/bin/$(RUBY_BASE_NAME)
          	--help
          	--with-freetds-dir
          	--with-freetds-include
          	--without-freetds-include=${freetds-dir}/include
          	--with-freetds-lib
          	--without-freetds-lib=${freetds-dir}/lib
          	--with-freetds-dir
          	--with-freetds-include
          	--without-freetds-include=${freetds-dir}/include
          	--with-freetds-lib
          	--without-freetds-lib=${freetds-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:
          
          /tmp/contents075463777/deps/0/vendor_bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0-static/tiny_tds-2.1.2/mkmf.log
          
          extconf failed, exit code 1
          
          Gem files will remain installed in
          /tmp/contents075463777/deps/0/vendor_bundle/ruby/2.4.0/gems/tiny_tds-2.1.2 for
          inspection.
          Results logged to
          /tmp/contents075463777/deps/0/vendor_bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0-static/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://repo.forge.lmig.com/content/groups/ets-ruby-gems/'` succeeds before
          bundling.
          
          In Gemfile:
            activerecord-sqlserver-adapter was resolved to 5.0.8, which depends on
              tiny_tds
          **ERROR** Unable to install gems: exit status 5
   Failed to compile droplet: Failed to run all supply scripts: exit status 15
   Exit status 223

sterankin avatar Jun 11 '19 12:06 sterankin

Ok the path was wrong, I was able to use the correct path to the compiled freetds folder:

BUNDLE_BUILD__TINY_TDS: "--with-freetds-dir=/tmp/app/vendor/freetds"

But its now failing with:

OUT] Starting health monitoring of container
2019-06-11T16:12:39.355+01:00 [APP/PROC/WEB/0] [ERR] /home/vcap/deps/0/vendor_bundle/ruby/2.4.0/gems/tiny_tds-2.1.2/lib/tiny_tds.rb:60:in `require': libsybdb.so.5: cannot open shared object file: No such file or directory - /home/vcap/deps/0/vendor_bundle/ruby/2.4.0/gems/tiny_tds-2.1.2/lib/tiny_tds/tiny_tds.so (LoadError)

So it can't find libsybdb.so? Its in my ROOT/vendor/freetds/lib folder, is there a way to change it to this?

sterankin avatar Jun 11 '19 15:06 sterankin