1

i tried for a few weeks to install mysql2 for ruby so i can use it with dashing. But the only thing i get is:

    gem install mysql2 --platform=ruby -- '--with-mysql-dir="/usr/include/mysql"'
Building native extensions with: '--with-mysql-dir="/usr/include/mysql"'
This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160203-7890-abpifj.rb extconf.rb --with-mysql-dir="/usr/include/mysql"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Cannot find include dir(s) /usr/include/mysql/include
-----
*** 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=/usr/local/rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
    --with-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.2.4/gems/mysql2-0.4.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.2.4/extensions/armv7l-linux/2.2.0/mysql2-0.4.2/gem_make.out

it is a Raspberry Pi 2 with Ruby 2.2.4 via RVM installed.

libmysqlclient-dev is installed.

mkmf.log tells me:

have_func: checking for rb_thread_blocking_region()... -------------------- no

"gcc -o conftest -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0/armv7l-linux-eabihf -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0/ruby/backward -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0 -I.  -D_FILE_OFFSET_BITS=64$
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘rb_thread_blocking_region’ undeclared (first use in this function)
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:13:32: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
WuGGu
  • 23
  • 7

4 Answers4

0

It looks like there is a bug in the mysql2 gem you're trying to install.

Try install the previous stable version, 0.3.X

gem install mysql2 --platform=ruby -v '~> 0.3.0'

If that doesn't work, try update your Ruby version.

sudo apt-get install ruby2.2

Or, if you can, upgrade

sudo apt-get install ruby2.3
Mihai Dinculescu
  • 19,743
  • 8
  • 55
  • 70
  • Ok i updated to ruby 2.3 and try this but i get all the time: checking for rb_thread_blocking_region()... no – WuGGu Feb 05 '16 at 12:33
0

Install the raspbian specific package, before trying to get the gem this worked for me.

apt-get install ruby-mysql2
ruby new projectname -dmysql
awiebe
  • 3,758
  • 4
  • 22
  • 33
0

I finally got around this error with the following:

apt-get install libmysql++-dev
Ian Atkin
  • 6,302
  • 2
  • 17
  • 24
0

you should

apt-get install libmariadbclient-dev
Viktor Leonets
  • 473
  • 4
  • 13