gem mysql2 on Raspberry Pi Ruby 2.2.4 - ruby

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]

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

Install the raspbian specific package, before trying to get the gem this worked for me.
apt-get install ruby-mysql2
ruby new projectname -dmysql

I finally got around this error with the following:
apt-get install libmysql++-dev

you should
apt-get install libmariadbclient-dev

Related

Unable to install tiny_tds on Mac OS X Yosemite v10.10.2

I am using RubyMine IDE on MAC OS X yosemite. On trying to install tiny_tds its giving the following error
sudo gem install tiny_tds -v '0.6.2'
Building native extensions. This could take a while...
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for sybfront.h... yes
checking for sybdb.h... yes
checking for tdsdbopen() in -lsybdb... no
freetds is missing.
* 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--enable-lookup
--disable-lookup
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/
--with-freetds-dir
--without-freetds-dir
--with-freetds-include
--without-freetds-include=${freetds-dir}/include
--with-freetds-lib
--without-freetds-lib=${freetds-dir}/
--with-iconvlib
--without-iconvlib
--with-sybdblib
--without-sybdblib
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2/ext/tiny_tds/gem_make.out
I have installed freetds
brew install freetds
and I can see it when I do brew list
but again when I do sudo gem install tiny_tds , it gives me error as freetds missing.
Please help.
Thanks
Did gem install tiny_tds not work?
FYI - Using sudo with gem install is not best practice.
As I posted at Homebrew / TinyTDS / FreeTDS bundle error, in addition to brew install freetds, you may also need to tell the gem where to find freetds.
If you are using bundler, you can do that by configuring bundler.
For example (depending where exactly homebrew installed freetds):
bundle config set --global build.tiny_tds --with-freetds-dir=/opt/homebrew/Cellar/freetds/1.3.3

Gem install pg works but bundle install fails

There is very lot of topics about this but I already try almost all of them with no success.
I'm on Mac OS X 10.9.4 Mavericks, I have the Postgres.app, and it seams to work fine, sudo gem install pg works too :
Building native extensions. This could take a while...
Successfully installed pg-0.17.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.17.1
Done installing documentation for pg after 2 seconds
1 gem installed
but when I try to bundle install I have the same error than every one else.
I already try bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
then bundle install
I have the Xcode Command Line Tools.
which psqlreturn /Applications/Postgres.app/Contents/Versions/9.3/bin/psql
which postgresreturn /Applications/Postgres.app/Contents/Versions/9.3/bin/postgres
Here is the error for bundle install:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
extconf failed, exit code 1
Gem files will remain installed in /var/folders/07/my1cl5xj7g9cknnp3y2zg_rh0000gn/T/bundler20140723-29399-1o0uzqn/pg-0.17.1/gems/pg-0.17.1 for inspection.
Results logged to /var/folders/07/my1cl5xj7g9cknnp3y2zg_rh0000gn/T/bundler20140723-29399-1o0uzqn/pg-0.17.1/extensions/universal-darwin-13/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
After days I finally found the problem source (ironically when I decide to give up, and move on).
When I do a
which bundle and which gem
They were not from the same ruby installation.
bundle was from rbenv and gem from the preinstalled ruby on mac osx.
might have the permission issue. can use:
sudo bundle install --without nothing --path vendor/cache

Issue installing therubyracer -v '0.12.1 succeeds before bundling on Windows

I am a Windows 8 user. I installed lib v8 with:
gem install libv8 -v '3.16.14.3' -- --with-system-v8
Now I am facing trouble with installing therubyracer. Following is the error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for main() in -lpthread... yes
checking for v8.h... no
*** 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}/
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--with-pthreadlib
--without-pthreadlib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/
/usr/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundle with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.16.14.3 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location
thanks,
The Mgmt
from /usr/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.1/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.12.1), and Bundler cannot
continue.
Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling.
I tried following other stackoverflow links but nothing seem to help
Because therubyracer-0.12.1 relys on libv8-3.16.14.7, you install libv8-3.16.14.3 rather than libv8-3.16.14.7 firstly, so there is a conflict.
It works for me:
$ gem uninstall libv8
$ gem install therubyracer -v '0.12.1'
$ gem install libv8 -v '3.16.14.3' -- --with-system-v8

Locomotive CMS bundle install fails rmagick 2.12.2 error

I am trying to install Locomotive CMS but I am getting an error regarding rmagick upon installation:
An error occurred while installing rmagick (2.12.2), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.12.2'` succeeds before bundling.
I checked the log and this is the error rmagick is showing:
$ gem install rmagick -v '2.12.2'
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:107:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:107:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for /usr/bin/clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.3.5... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... yes
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick... no
Can't install RMagick 2.12.2. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.
*** 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=.rvm/rubies/ruby-2.1.0/bin/ruby
--with-MagickCorelib
--without-MagickCorelib
--with-Magicklib
--without-Magicklib
extconf failed, exit code 1
Gem files will remain installed in .rvm/gems/ruby-2.1.0/gems/rmagick-2.12.2 for inspection.
Results logged to .rvm/gems/ruby-2.1.0/extensions/x86_64-darwin-12/2.1.0-static/rmagick-2.12.2/gem_make.out
I've found similar issues on SO and Google but I've been trying all sorts of fixes for about 3 hours now and still can't get it to work. Please advise, thanks!

RVM + Ruby 1.9.2 + Rmagick + Lion = System Works, RVM Doesn't

I've installed Ruby 1.9.2 through RVM on a fresh install of OS X Lion. I have installed ghostscript and imagemagick through homebrew, and when running gem install rmagick using RVM, it fails. When using gem install rmagick on the system install of ruby, it works just fine.
This is the error that is produced:
─wedtm#WedHQ ~/.rvm/gems/ruby-1.9.2-p290/cache ‹ruby-1.8.7›
╰─$ gem install rmagick 1 ↵
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/wedtm/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... yes
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagick++... no
Can't install RMagick 2.13.1. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.
*** 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=/Users/wedtm/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
--with-MagickCorelib
--without-MagickCorelib
--with-Magicklib
--without-Magicklib
--with-Magick++lib
--without-Magick++lib
Gem files will remain installed in /Users/wedtm/.rvm/gems/ruby-1.8.7-p352/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/wedtm/.rvm/gems/ruby-1.8.7-p352/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
What could be causing this? Any ideas on how to get RVM to see the imagemagick like it's should?
The magick-installer script ( https://github.com/maddox/magick-installer ) does a fantastic job of installing ImageMagick on the mac. When I installed without using this script, the install would appear to succeed but the gem would never find the installation.
Using this script, I succeeded with installation where I had failed many times previously. Good luck :)

Resources