rails-sqlserver / heroku-buildpack-freetds Goto Github PK
View Code? Open in Web Editor NEWThis is a Heroku buildpack for vendoring the FreeTDS binaries into your project.
License: MIT License
This is a Heroku buildpack for vendoring the FreeTDS binaries into your project.
License: MIT License
Cedar-14 is supported through April 2019, but is deprecated: https://devcenter.heroku.com/articles/stack
https://devcenter.heroku.com/articles/heroku-16-stack
I'm possibly willing to help, hopefully I'm not the only one who might need this.
Hi,
We upgraded to heroku-18 and now the buildpack breaks on new deploys / our review apps.
Help would be much appreciated ๐๐๐
https://github.com/rails-sqlserver/heroku-buildpack-freetds/blob/master/bin/compile#L86 $PATH
should be escaped otherwise the PATH expanded at the .profile.d script is created rather than when the script runs on the dyno booting.
This is causing the PATH
to be set at the time the .profile.d
the script runs to be lost.
The current .profile.d
is broken in a few ways. It does not take into account the difference between build time and runtime differences. On Heroku the build directory will be different than the runtime directory. To account for this other buildpacks do not hardcode paths, but instead use $HOME
in their .profile.d
scripts. The other problem is that you're completely obliterating any prior $PATH
, so if any other buildpack profile.d
script runs before this one, this will wipe it out. That's because it does not include a :$PATH
at the end to indicate you want to prepend to the PATH instead of overwriting it.
An example from heroku run bash
~ $ cat .profile.d/freetds.sh | grep " PATH="
export PATH="/app/freetds/bin:/tmp/build_b5beced7/.heroku/activestorage-preview/usr/bin:/usr/local/bin:/usr/bin:/bin"
Should be:
~ $ cat .profile.d/freetds.sh | grep " PATH="
export PATH="$HOME/freetds/bin:$PATH"
You can see this pattern used in other buildpacks:
~ $ cat .profile.d/000_activestorage_preview.sh | grep " PATH="
export PATH="$HOME/.heroku/activestorage-preview/usr/bin:$PATH"
While the $HOME
part isn't strictly necessary, it's a good practice. Not preserving prior $PATH
can and does cause problems. When you use this buildpack along with the activestorage preview buildpack then ffmpeg
cannot be found:
โ๏ธ 3.1.2 ๐ /tmp/3ce01b21867258f6d576c61710222b89 (main)
$ heroku run which ffmpeg
Running which ffmpeg on โฌข warm-spire-40708... up, run.2284 (Free)
/app/.heroku/activestorage-preview/usr/bin/ffmpeg
$ heroku buildpacks:add https://github.com/rails-sqlserver/heroku-buildpack-freetds
Buildpack added. Next release on warm-spire-40708 will use:
1. https://github.com/heroku/heroku-buildpack-activestorage-preview
2. https://github.com/rails-sqlserver/heroku-buildpack-freetds
Run git push heroku main to create a new release using these buildpacks.
$ git push heroku main
Enumerating objects: 2, done.
Counting objects: 100% (2/2), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 270 bytes | 270.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpacks:
remote: 1. https://github.com/heroku/heroku-buildpack-activestorage-preview
remote: 2. https://github.com/rails-sqlserver/heroku-buildpack-freetds
remote: -----> ActiveStorage Preview app detected
remote: -----> Installing binary dependencies for ActiveStorage Preview
remote: Reusing cache
remote: Downloading packages..
remote: Installing packages.....
remote: -----> FreeTDS app detected
remote: BIN_DIR=/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e/bin, ROOT_DIR=/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e, BUILD_DIR=/tmp/build_59bb7b24, CACHE_DIR=/tmp/codon/tmp/cache, pwd=/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e
remote: -----> [2022-04-25 11:59:17] FreeTDS 1.00.109 building in /tmp/build_59bb7b24
remote: -----> [2022-04-25 11:59:17] Creating .profile.d entry
remote: configured APP env vars:
remote: export PATH="/app/freetds/bin:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/bin:/usr/local/bin:/usr/bin:/bin"
remote: # tiny_tds extconf.rb uses FREETDS_DIR
remote: # https://github.com/rails-sqlserver/tiny_tds/blob/5046755ca91594003f8b3ca541d136f3ed859973/ext/tiny_tds/extconf.rb#L36-L38
remote: export FREETDS_DIR="/app/freetds"
remote: export LD_LIBRARY_PATH="/app/freetds/lib:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu/nss"
remote: export LD_RUN_PATH="/app/freetds/lib:/usr/local/lib"
remote: export LIBRARY_PATH="/app/freetds/lib:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu/nss"
remote: export SYBASE="/app/freetds"
remote: Cached files not found - downloading and unpacking...
remote: -----> [2022-04-25 11:59:18] Building FreeTDS against OpenSSL OpenSSL 1.1.1f 31 Mar 2020
remote: -----> [2022-04-25 12:00:56] Testing build
remote: Compile-time settings (established with the "configure" script)
remote: Version: freetds v1.00.109
remote: freetds.conf directory: /app/freetds/etc
remote: MS db-lib source compatibility: no
remote: Sybase binary compatibility: no
remote: Thread safety: yes
remote: iconv library: yes
remote: TDS version: 7.3
remote: iODBC: no
remote: unixodbc: no
remote: SSPI "trusted" logins: no
remote: Kerberos: no
remote: OpenSSL: yes
remote: GnuTLS: no
remote: MARS: no
remote: -----> [2022-04-25 12:00:56] Caching FreeTDS installation
remote: Unpacking cached files...
remote: configured BUILDPACK env vars:
remote: declare -x FREETDS_DIR="/tmp/build_59bb7b24/freetds"
remote: declare -x LD_LIBRARY_PATH="/tmp/build_59bb7b24/freetds/lib:/app/freetds/lib:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu/nss"
remote: declare -x LIBRARY_PATH="/tmp/build_59bb7b24/freetds/lib:/app/freetds/lib:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/lib/x86_64-linux-gnu/nss"
remote: declare -x PATH="/tmp/build_59bb7b24/freetds/bin:/app/freetds/bin:/tmp/build_59bb7b24/.heroku/activestorage-preview/usr/bin:/usr/local/bin:/usr/bin:/bin"
remote: declare -x SYBASE="/app/freetds"
remote: Install of FreeTDS 1.00.109 complete
remote: END Running script: compile
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote:
remote: -----> Compressing...
remote: Done: 55.4M
remote: -----> Launching...
remote: Released v5
remote: https://warm-spire-40708.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/warm-spire-40708.git
78d310e..5439868 main -> main
โ๏ธ 3.1.2 ๐ /tmp/3ce01b21867258f6d576c61710222b89 (main)
$ heroku run which ffmpeg
Running which ffmpeg on โฌข warm-spire-40708... up, run.7308 (Free)
Note that before adding this buildpack which ffmpeg
returns a result, after adding this buildpack it does not.
After this PR was merged, we immediately started seeing the following error during heroku deployment
-----> FreeTDS app detected
BIN_DIR=/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e/bin, ROOT_DIR=/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e, BUILD_DIR=/tmp/build_c95bba3f, CACHE_DIR=/tmp/codon/tmp/cache, pwd=/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e
-----> [2023-01-18 09:57:46] FreeTDS 1.1.15 building in /tmp/build_c95bba3f
-----> [2023-01-18 09:57:46] Creating .profile.d entry
configured APP env vars:
export PATH="/app/freetds/bin:$PATH"
# tiny_tds extconf.rb uses FREETDS_DIR
# https://github.com/rails-sqlserver/tiny_tds/blob/5046755ca91594003f8b3ca541d136f3ed859973/ext/tiny_tds/extconf.rb#L36-L38
export FREETDS_DIR="/app/freetds"
export LD_LIBRARY_PATH="/app/freetds/lib:/usr/local/lib"
export LD_RUN_PATH="/app/freetds/lib:/usr/local/lib"
export LIBRARY_PATH="/app/freetds/lib:/usr/local/lib"
export SYBASE="/app/freetds"
Unpacking cached files...
/tmp/codon/tmp/buildpacks/89c5ba58d4a923295058e848b2f0751fa8f4f45e/bin/compile: line 113: grep: command not found
END Running script: compile
! Push rejected, failed to compile FreeTDS app.
! Push failed
Switching to the commit just before the last one resolved the issue.
This is on heroku-18 stack, not sure about the recent versions.
The README refers to the x-b-e fork, which appears to be the same code. Is that just a typo?
The TinyTDS gem does not load when deploying to Heroku with the Heroku-18 stack. I have specified heroku-buildpack-freetds as the first buildpack in the sequence, followed by the standard heroku/ruby pack.
The app is running Rails 6, but I encountered the same error with 5.8. I've attached a copy of the trace of the push.
cannot install bundler when i deploy with sql server.. May you help me?
I believe there is some configuration problem with this heroku buildpack and the heroku-22 stack. Here are a few things I have tried:
FREETDS_VERSION
settings (and none at all)tsql
connection command to connect almost instantaneously to a variety of mssql databases (one on ec2 and two on azure), but the same command times out on heroku bash prompt:~ $ tsql -H ***.rds.amazonaws.com -p 1433 -U *** -P ***
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
103Error 20002 (severity 9):
Adaptive Server connection failed
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
~ $ nslookup <host1>.us-east-1.rds.amazonaws.com
Server: <ip address>
Address: <ip address>#53
Non-authoritative answer:
<host1>.rds.amazonaws.com canonical name = <host name>.compute-1.amazonaws.com.
Name: <host name>.compute-1.amazonaws.com
Address: <another ip address>
~ $ nc -zv <host1>us-east-1.rds.amazonaws.com 1433
Connection to <host1>.us-east-1.rds.amazonaws.com (<another ip address>) 1433 port [tcp/ms-sql-s] succeeded!
Any ideas would be greatly appreciated!
Hello! I've run into an issue using an Aptfile
and the heroku-community/apt
buildpack alongside FreeTDS that I can't seem to get sorted.
I've created a minimum reproducible example here. Note that without the FreeTDS buildpack, the application runs successfully. The application itself deploys successfully, but running heroku run rails console
is enough to trigger the exception (captured in the repo above).
I'm not quite sure how to proceed here and would love to hear any workarounds others have tried.
I just saw this thread on the adapter and I wonder if it would help to have a small section in the README to talk about DABASE_URL?
rails-sqlserver/activerecord-sqlserver-adapter#497 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.