I am running Ruby 1.9.3 on Debian, with no Rails. I have a script that needs mysql, so I ran gem install mysql, and it installed fine.
However, when I execute the script I get a "cannot load such file" error.
/usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- mysql (LoadError)
    from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from db-test.rb:5:in `<main>'
Further info: I have updated to RBENV, but now the mysql won't install.
ruby --version gives:
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
which ruby gives:
/home/poconnor/.rbenv/shims/ruby
Output of gem environment is:
    RubyGems Environment:
  - RUBYGEMS VERSION: 2.1.11
  - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/poconnor/ruby/gems
  - RUBY EXECUTABLE: /home/poconnor/.rbenv/versions/1.9.3-p484/bin/ruby
  - EXECUTABLE DIRECTORY: /home/poconnor/ruby/gems/bin
  - SPEC CACHE DIRECTORY: /home/poconnor/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/poconnor/ruby/gems
     - /lib/ruby/gems/1.9.3
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/poconnor/.rbenv/versions/1.9.3-p484/bin
     - /home/poconnor/.rbenv/libexec
     - /home/poconnor/.rbenv/plugins/ruby-build/bin
     - /home/poconnor/.rbenv/shims
     - /home/poconnor/.rbenv/bin
     - /usr/lib/lightdm/lightdm
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /usr/java/jdk1.7.0_17/bin
     - /usr/java/jdk1.7.0_17/bin
     - /usr/java/jdk1.7.0_17/bin
     - /usr/java/jdk1.7.0_17/bin
When I try gem install mysql I get:
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.
    /home/poconnor/.rbenv/versions/1.9.3-p484/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
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.
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=/home/poconnor/.rbenv/versions/1.9.3-p484/bin/ruby
        --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
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mygcclib
        --without-mygcclib
        --with-mysqlclientlib
        --without-mysqlclientlib
Gem files will remain installed in /home/poconnor/ruby/gems/gems/mysql-2.9.1 for inspection.
Results logged to /home/poconnor/ruby/gems/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
Help much appreciated on this.
 
     
     
    