You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to install the mysql2 gem on Heroku's latest stack heroku-20 (Ubuntu 20.04), but have it compile against MySQL 5.7. I've added the libmysqlclient-dev_5.7.32 package via the apt buildpack, but I'm not convinced it's being compiled against.
Whenever the gem is loaded via require "mysql2", I get the error:
Heroku's stack does have the MySQL 8 library as well, in /lib/x86_64-linux-gnu/. The apt-provided (5.7) library is available in /app/.apt/usr/lib/x86_64-linux-gnu, and that path is first in $LD_LIBRARY_PATH. It's also what mysql_config points to.
The other complication is that Heroku's build process occurs in a separate randomly generated path (so that's where the gem and the apt package first exist) - which means the gem's .so file lives temporarily at something like /tmp/build_bd61275a/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so. This means I can't hardcode library paths as part of the mysql2 gem compilation, because the paths change. It also means I can't auto-require the mysql2 gem as part of a Rails assets compilation, because I hit the same error, but with this build path instead of in /app/. To get around this, it's listed as gem "mysql2", require: false in my Gemfile.
I realise this might be a bit of an edge case, but if anyone can provide pointers to help debug, that'd be great. I'm a bit out of my depth here with compiled dependencies and library paths and such. Has anyone seen the error message before? Does it mean that the gem's compiled against the wrong version of MySQL? Or something else? Is there any way to confirm which MySQL library files it's using?
(And compiling for MySQL 8+ isn't an option - I need mysql2 to talk to Sphinx v2.2.11, which predates MySQL v8).
The text was updated successfully, but these errors were encountered:
I've spent a bit more time on this today, and it seems the issue - at least, the visible issue - is that it wasn't picking up libstdc++, even though it is present. The fix, at least on Heroku, is to set the LD_PRELOAD environment variable (which in my cases wasn't previously set to anything). I also need to ensure mysql2 picks up the apt-buildpack-provided mysql_config. So:
Along with https://cdn.mysql.com/Downloads/MySQL-5.7/libmysqlclient-dev_5.7.32-1ubuntu18.04_amd64.deb in my Aptfile, I'm finding that this is enough to get mysql2 working on Heroku's heroku-18 buildpack. Something's not quite right for heroku-20 though, but that's a different problem. The focus of this issue was the undefined symbol error, and setting LD_PRELOAD fixed that.
I'm trying to install the
mysql2
gem on Heroku's latest stackheroku-20
(Ubuntu 20.04), but have it compile against MySQL 5.7. I've added thelibmysqlclient-dev_5.7.32
package via the apt buildpack, but I'm not convinced it's being compiled against.Whenever the gem is loaded via
require "mysql2"
, I get the error:Heroku's stack does have the MySQL 8 library as well, in
/lib/x86_64-linux-gnu/
. The apt-provided (5.7) library is available in/app/.apt/usr/lib/x86_64-linux-gnu
, and that path is first in$LD_LIBRARY_PATH
. It's also whatmysql_config
points to.The output from
ldd
doesn't mention MySQL at all though:The other complication is that Heroku's build process occurs in a separate randomly generated path (so that's where the gem and the apt package first exist) - which means the gem's
.so
file lives temporarily at something like/tmp/build_bd61275a/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so
. This means I can't hardcode library paths as part of the mysql2 gem compilation, because the paths change. It also means I can't auto-require themysql2
gem as part of a Rails assets compilation, because I hit the same error, but with this build path instead of in /app/. To get around this, it's listed asgem "mysql2", require: false
in my Gemfile.I realise this might be a bit of an edge case, but if anyone can provide pointers to help debug, that'd be great. I'm a bit out of my depth here with compiled dependencies and library paths and such. Has anyone seen the error message before? Does it mean that the gem's compiled against the wrong version of MySQL? Or something else? Is there any way to confirm which MySQL library files it's using?
(And compiling for MySQL 8+ isn't an option - I need mysql2 to talk to Sphinx v2.2.11, which predates MySQL v8).
The text was updated successfully, but these errors were encountered: