Reputation: 10517
I installed redmine from ports on my FreeBSD 11.3 Now trying to access it from browser and it crashes. error log displays the following.
/usr/local/lib/ruby/gems/2.6/gems/activesupport-4.2.11.1/lib/active_support/core_ext/object/duplicable.rb:111: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
/usr/local/lib/ruby/gems/2.6/gems/mysql2-0.4.10/lib/mysql2/mysql2.so: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.6.6p146 (2020-03-31 revision 67876) [amd64-freebsd11]
-- Control frame information -----------------------------------------------
c:0027 p:-4313666350 s:0131 e:000130 TOP [FINISH]
c:0026 p:---- s:0128 e:000127 CFUNC :require
c:0025 p:0261 s:0123 e:000122 TOP /usr/local/lib/ruby/gems/2.6/gems/mysql2-0.4.10/lib/mysql2.rb:31 [FINISH]
c:0024 p:---- s:0119 e:000118 CFUNC :require
c:0023 p:0033 s:0114 e:000113 BLOCK /usr/local/lib/ruby/gems/2.6/gems/bundler-2.0.2/lib/bundler/runtime.rb:81 [FINISH]
the output is much longer, I shortified it, this is the top most error in the stack. I'm not sure which community it would be better to address this question so I decided to ask here first.
Upvotes: 4
Views: 6690
Reputation: 548
I ran into this issue on a Rails project using Ruby 2.7.3 on Ubuntu 24.04 LTS.
The reason why this crash happens to me is that indeed, MySQL 8 relies on OpenSSL 3.0 which Ruby 2.7.3 does not support.
Since upgrading Ruby or using MariaDB is not on the table for my specific use case, the simplest workaround for Rails is the following:
On config/database.yml
:
test:
adapter: mysql2
host: <%= Rails.application.credentials.config[:test_host] %>
username: <%= ENV.fetch('LOCAL_USERNAME', Rails.application.credentials.config[:test_username]) %>
password: <%= ENV.fetch('LOCAL_PASSWORD', Rails.application.credentials.config[:test_password]) %>
This solution basically expects the host, username and password set on an environment variable, and if the environment variable is not set it simply falls back to the test
environment credentials.
On my specific use case this means I can set the Environment Variable LOCAL_PASSWORD
as an empty string and run my tests without compromising my actual test environment security, since the actual value is set on config/credentials.yml
Again, it's not a perfect solution but it works.
Upvotes: 1
Reputation: 1324
I faced a similar issue today on ubuntu 20.04 and msql2 -v 0.5.1. Solution to the problem:
sudo apt remove libmysqlclient-dev
sudo apt install libmariadbclient-dev
gem install mysql2 -v '0.5.1'
here it is described in more detail: https://github.com/brianmario/mysql2/issues/1075
or for later versions:
sudo apt remove libmariadbd-dev
sudo apt install libmariadbd-dev
gem install mysql2 -v 'your version'
Upvotes: 13
Reputation: 11
libmariadbclient-dev didn't exist on ubuntu 22 for me : had to install libmariadbd-dev instead and re-install mysql2 gem.
Upvotes: 1