Ruby on Rails installation issue (Windows) - mysql

I installed Ruby 2.0.0 and DevKit from RuyInstaller. I have an error message when I'm creating new project:
rails new testtest -d mysql
..... a lot of output here ........
Installing mysql2 (0.3.14)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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.
How can I install dependencies to make this gem without any errors?

You need MySQL 32-bit (or MySQL Connector C) to compile mysql2 gem compiling on Windows (even if you are using a 64-bit version of the OS).
Follow these steps:
Download MySQL Server 32-bit .zip file (Alternatively MySQL Connector C is also fine)
Copy libmysql.dll to %RUBY_HOME%\bin (or simply add MySQL 32-bit lib directory to PATH)
Install mysql2 gem with --with-mysql-lib and --with-mysql-include options
gem install mysql2 -- '--with-mysql-lib="c:\path\to\32-bit-MySQL-Server\lib\opt" --with-mysql-include="c:\\path\to\32-bit-MySQL-Server\include"'

Here is my story. Tried to install mysql2 gem on windows 7 with devkit.
First you need to install connector libraries and headers.
Don't use default folder "Program Files", gem failed to include folders with spaces.
I've substed connector folder through subst X:\ "C:\Program File\Mysql Connector 6 C\"
and then used following cmd:
gem install mysql2 -- --with-mysql-dir=X:\
Then realised that I'm using 64 bit connector libraries with 32 bit ruby.
Reinstalled connector.
And then gem was successfully installed.
But failed to run, complaining on missing mysql dll. So, I've put libmysql.dll and *.lib to ruby\bin folder. And after all this was able to user mysql2 gem.

Related

Fail to install MySQL2 gem on Mac

I'm trying to install mysql2 gem for rails applications but it gives me following error while running sudo gem install mysql2
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /Users/ateeq/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.4.5/ext/mysql2
/Users/ateeq/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20161103-83594-10ft58j.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
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
checking for rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql/5.7.16/lib
-----
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/ateeq/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.5/mkmf.log
current directory: /Users/ateeq/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/ateeq/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/ateeq/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.4.5 for inspection.
Results logged to /Users/ateeq/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.5/gem_make.out
I installed rails via brew & rbenv. Versions are mentioned below:
Ruby Version: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
Rails Version: Rails 4.2.6
MySql Version: mysql-5.7.16
Pull up an instance of Terminal and run:
brew doctor
It's likely that one or more dependencies for building the mysql gem are out of date.
You'll have to run:
brew update
You probably also upgraded to the Sierra release of OS X recently. Make sure your XCode command line tools is up to date. Run:
xcode-select --install
Make sure you accept the license for the new version of XCode by running:
sudo xcodebuild -license
Here is my solution for above error:
I just uninstalled mysql by running brew remove mysql and then run following command to install mysql2 gem sudo gem install mysql2. It worked for me. After this, I reinstalled mysql by running brew install mysql.
P.s. I don't know about this behaviour. If anyone can explain, it'd be great.

Weird mysql error `checking for main() in -llibmysql... no`

I've successfully installed the gem mysql2 with ruby under windows in the past, but now it's showing a weird error
checking for main() in -llibmysql... no
There is no typo, my console really shows -llibmysql and not -libmysql (and I think it should even be just libmysql without any dash)
I have followed all the instructions from this link, and my command looks like
gem install mysql2 -- '--with-mysql-lib="c:\Dev\MySQL_Connector\lib" --with-mysql-include="c:\Dev\MySQL_Connector\include"'
...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Bibliotheques/Dev/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib=c:\Dev\MySQL_Connector\lib --with-mysql-in
clude=c:\Dev\MySQL_Connector\include
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using --with-mysql-dir=c:\Dev\MySQL_Connector
-----
checking for main() in -llibmysql... no

can't install mysql2 gem! Failed to build gem native extension

Been trying to install the mysql2 gem for couple of days, let me tell you where I am stuck and describe the steps I took.
The CMD command that throws an error is: gem install --http-proxy http://web1-proxy:8088 mysql2 !!
Error description:
Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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.
To begin from the start, I installed Ruby 1.9.3, then Rails 4.1.1.
How I installed Ruby:
From rubyinstaller.org (downloads) I took rubyinstaller-1.9.3-p448.exe
Checked "Add Ruby executables to your PATH" and "associate .rb and .rbw files with this ruby installation"
From the same page I installed the Dev Kit (DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe) in C:\RubyDevKit
I went to RubyDevKit in cmd and typed:
dir dk.rb
ruby dk.rb init
ruby dk.rb install
I launched irb (typed irb in C:\RubyDevKit) to confirm ruby works and it does.
How I installed rails:
Went to C:\Ruby193\bin from cmd and typed: gem install rails
this threw an error (established connection failed because connected host has failed to respond) which I fixed by going to Internet Options - Connections - LAN Settings - Out of the 4 options, I only checked the last 2 options: Use a proxy server for your LAN (address: web1-proxy, port number given to me by the IT)
After this I migrated from CMD to "c:\Sites" and typed: set HTTP_PROXY=http://web1-proxy:8088
Then: From CMD C:\Ruby193\bin> gem install --http-proxy http://web1-proxy:8088 rails
Then: C:\Sites> rails new app2
to confirm it works: C:\Sites\app2> rails server
Installation steps I followed for Mysql:
From http://dev.mysql.com/downloads/mysql/
(Note: MySQL Installer is 32 bit, but will install both 32 bit and 64 bit binaries.)
Picked the smaller package and RAN the file. During the installation:
Chose “developer default”
on the next page agreed to installing pre-requirements (MySql Server, .NET, Connectors etc).
Config Type = “Development Machine”; I checked: “Enable TCP/IP Networking”, Port number = 3306, checked: Open Firewall port for network access.
Set MySql root pwd; didn’t add user at this stage
Windows Service name: MySQL 55, Ran MySQL Server at System startup; Ran Win Service as: Standard System Account
Didn’t start MySql workbench after setup
The ODBC Connector 5.3.2 failed to install during the mysql installation, so afterwards I followed this workaround: http://dev.mysql.com/downloads/connector/ . Clicked on the "Connector/ODBC" link. Made sure "Select Platform" showed "Microsoft Windows". Clicked on the appropriate download button for MSI Installer. After downloading ran the .msi file.
How I debugged my problem so far:
Copied libmysql.dll from C:\Program Files\MySQL\MySQL Server 5.5\lib to C:\Ruby193\bin and tried again - no luck
Copied also the libmysql.lib file from C:\Program Files\MySQL\MySQL Server 5.5\lib to C:\Ruby193\bin and tried again - no luck
Tried gem install --HTTP-PROXY http://web1-proxy:8088 mysql2 --no-rdoc --no-ri -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.6\lib\" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.6\include\"' - no luck
Tried all 3 of the above solutions with previous versions of mysql installed (using again the installer) and with previous ODBC Connectors.
Help!!

mysql2-0.3.11 can not be installed

Hi I want to install Gitlab on Debian 7.0 when i want to install the bundle i get follor error by mysql2-0.3.11
root#v22013051598612672:/home/git/gitlab# gem install mysql2 -v '0.3.11'
Fetching: mysql2-0.3.11.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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.
Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1 /gems/mysql2-0.3.11 for inspecti on.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
I have you a idea?
Mfg user2182545 (ternes3)
PS: I need it for GitLAB
Try to install mysql + libraries via apt-get install mysql-server libmysqlclient libmysqlclient-dev mysql-client mysql-common
The issue 754 mentions seeing this error even after gem install mysql2 and apt-get install libmysqlclient-dev.
But it also adds:
EDIT: Solved!
sudo apt-get install libmariadbclient16-dev
Check if this is the actual missing piece on your Debian.

Can't run install MySQL gem Fedora 14, even after installing mysql-devel, ruby-devel, and rubygems

I'm trying to install the mysql gem via
sudo gem install mysql --version 2.7
However, I get the following error:
Building native extensions. This could take a while...
...........
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... 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.
Any ideas?
somethings to try:
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
of course use path of where your mysql_config is. mysql_config will be there if you've installed a mysql client
gem install mysql -- \
--with-mysql-include=/usr/include/mysql \
--with-mysql-lib=/usr/lib/mysql
use paths of where your lib and headers are for mysql.