0

I've installed xampp, made a mysql database, installed Ruby on Rails, made a site, and when I tried installing mysql2, with "gem install mysql2" on guibash, I get this error:

$ ––gem install mysql2

ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.
    current directory: C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.5.4/ext/mysql2
C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe -I C:/RailsInstaller/Ruby2.3.3/lib/ruby/site_ruby/2.3.0 -r ./siteconf20220523-8620-1rn7wab.rb extconf.rb
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... no
checking for main() in -lmysqlclient... no
mysql client is missing. Check your installation of MySQL or Connector/C, and try again.
*** 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=C:/RailsInstaller/Ruby2.3.3/bin/$(RUBY_BASE_NAME)
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
  C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/mysql2-0.5.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.5.4 for inspection.
Results logged to C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/mysql2-0.5.4/gem_make.out
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
-------------------------------

Now for the sake of not repeating this wall of text, let's call that error A. I've tried also tried gem install mysql2 --platform=ruby (error A).

Now the only way I've been able to install mysql is by downloading the the lib and using : gem install mysql2 -- '--with-mysql-dir=C:\MySQLConn' with MySQLConn including the library, and that does it.

$ gem list mysql2

mysql2 (0.5.4)

But whenever I use "Rails server" I get:

C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/definition.rb:486:in `materialize': Could not find mysql2-0.5.4 in any of the sources (Bundler::GemNotFound)
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/definition.rb:191:in `specs'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/definition.rb:239:in `specs_for'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:18:in `setup'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler.rb:151:in `setup'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `block in <top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:136:in `with_level'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:88:in `silence'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:85:in `require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:85:in `require'
        from C:/Sites/imagenes/config/boot.rb:3:in `<top (required)>'
        from bin/rails:3:in `require_relative'
        from bin/rails:3:in `<main>'

What can I try to resolve this?

halfer
  • 19,471
  • 17
  • 87
  • 173

1 Answers1

0

This question has lots of answers that should help you get things working. Most questions have already been asked on StackOverflow, so be sure to look them up beforehand and your answer may already be there!

Jack L
  • 27
  • 1
  • 5