Installation Error - Rails MySQL2 Gems on Windows 7 - ruby-on-rails

I am not able to install the latest version of mysql2 gem for my rails application. I have already tried out the options suggested in this answer. However the older version installed without any errors!
gem uninstall mysql2
gem install mysql2 -v 0.2.6
Following is the error that pops up whenever I try to install the latest version of mysql2 gem
C:\Users\EcoAd>gem install mysql2 -v '0.3.16' -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.6\lib" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.6\include"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.6\lib" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.6\include"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20140923-3596-odrqgn.rb extconf.rb --with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.6\lib" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.6\include"
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
Using --with-mysql-dir=C:\Program Files\MySQL\MySQL Server 5.6
checking for main() in -llibmysql... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make clean
Makefile:165: *** target pattern contains no `%'. Stop.
make
Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.16 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/mysql2-0.3.16/gem_make.out
C:\Users\EcoAd>

Related

Cannot install mysql2 gem on Windows 10

I have 8.0.30 version of mysql and ruby v3.0.4 installed. I'm able to run mysql on my system and create databases but I cannot run this command:
gem install mysql2 -v '0.5.4' -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 8.0\lib" --withmysql-include="C:\Program Files\MySQL\MySQL Server 8.0\include"'
I getting following error:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enc_interned_str() in ruby.h... yes
checking for -lmysqlclient... no
-----
mysql client is missing. Check your installation of MySQL or Connector/C, and try again.
-----
*** extconf.rb failed ***
Do you have the client lib files (not just the server) installed locally?
https://dev.mysql.com/downloads/c-api/
I know this isn't a direct solution, but I'd strongly encourage having a look at developing under WSL2. Developing Ruby apps under native Windows often involves a lot more mucking about that just using the Linux subsystem.

Cannot install mysql2 gem for Rails project

I've looked at and tried just about everything on the topic here at Stackoverflow.com and still can't figure this out...
When I 'gem install mysql2' I get a permissions error. when I 'sudo gem install mysql2' I get the following:
Teds-MacBook-Pro:~ tedmartin$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
/Users/tedmartin/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20170420-50202-1nekuvd.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-connector-c/6.1.9/lib
-----
creating Makefile
current directory: /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.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 -l-lpthread
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/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5 for inspection.
Results logged to /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-15/2.4.0-static/mysql2-0.4.5/gem_make.out
Anyone who has an idea, suggestion, tip, fix, etc... I'd be really grateful.
Thanks!
From the answer at this question, running the following worked for me
gem install mysql2 --source 'https://rubygems.org/' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
I ran into this same issue on Mojave, and none of the previous answers worked for me but this commands mentioned in this Github issue comment did
Step 1.
brew install openssl
Step 2.
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
In my case I already had openssl installed so it was really the export command that solved the problem.
Make sure openssl is installed on Mac via Homebrew.
brew install openssl
Install mysql2 gem.
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
If the bug is not fixed, this above solution is the last one
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Another solution if the above does not work.
cd /usr/local/Cellar/openssl/1.0.2s/lib/
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib
This worked for me on macOS Catalina:
Make sure you have openssl installed. If not:
brew install openssl
Then do the gem install:
gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"
Try this:
which mysql
Then, use the output-result to install the gem using the existing mysql installation directory:
gem install mysql2 -- --with-mysql-dir=<mysql-installation-directory>
It away working for me after 2h crazy
Unstall Ruby and Install Ruby v2.6.6
Run command line as Administrator gem install mysql2
Install rails gem install rails
Create new project rails new my_proj -d mysql
Work 100% in Windown

noi4r gem install issues

In trying to install the nio4r gem. I tried
gem install nio4r -v '1.0.0'
The error that pops up is:
Building native extensions. This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.
/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150406-11564-1qtifmf.rb extconf.rb
checking for rb_thread_blocking_region()... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
warning use "ruby/io.h" instead of "rubyio.h"
...
What am I getting wrong? Is it an issue with my RVM?
With some basic updates, I was able to get it to work.
bundle update
and then
bundle
installs the gem.
Thanks to https://github.com/celluloid/nio4r/issues/46
Another approach would be to install a later version of ruby with RVM and do bundle again. Both works

Fail to install fxruby on Mac 10.9.2

I use homebrew to install the fox library successfully.
When I try sudo gem install fxruby, it fails.
The error message is shown below.
Building native extensions. This could take a while...
ERROR: Error installing fxruby:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for sys/time.h... yes
checking for signal.h... yes
checking for deflate() in -lz... yes
checking for png_create_read_struct() in -lpng... yes
checking for jpeg_mem_init() in -ljpeg... no
checking for TIFFSetErrorHandler() in -ltiff... no
checking for XftInit() in -lXft... yes
checking for XShmQueryVersion() in -lXext... yes
checking for XFindContext() in -lX11... yes
checking for glXCreateContext() in -lGL... yes
checking for gluNewQuadric() in -lGLU... yes
checking for FXRbCommon.h in ./include... no
creating Makefile
make "DESTDIR="
compiling librb.c
compiling core_wrap.cpp
core_wrap.cpp:593:10: fatal error: 'FXRbCommon.h' file not found
#include "FXRbCommon.h"
^
1 error generated.
make: *** [core_wrap.o] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/fxruby-1.6.28 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/fxruby-1.6.28/ext/fox16_c/gem_make.out
I had the exact same problem (Mac 10.9.3) and followed the advice on https://github.com/larskanis/fxruby/issues/7 (actually reference a Debian installation)
This was basically to try sudo gem install fxruby -- --with-cppflags=-I./include
Worked for me
Hope it helps.

I have done "brew install postgresql" got 9.0.2 but running "gem install pg" I get missing library

gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.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 *
It looks like you either need to specify your postgres lib directory:
gem install pg -- --with-pg-dir=/path/to/pg_dir
or perhaps a 32bit vs.64 bit compatibility problem
ARCHFLAGS='-arch x86_64' gem install pg
"env ARCHFLAGS="-arch x86_64" gem install pg" worked for me when using Snow Leopard.

Resources