0

I am getting the below error while using the MySQL gem; Tried mysql2 and it also gives the same error.

-bash-4.1$ gem list

*** LOCAL GEMS ***

mysql (2.9.1)

-bash-4.1$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]


-bash-4.1$ irb
irb(main):001:0> require 'mysql'
NameError: uninitialized constant Mysql
    from ./mysql.rb:10
    from (irb):1:in `require'
    from (irb):1
    from :0
irb(main):002:0> 

Please let me know if there is a solution for this; thanks!

2 Answers2

0

Are you using bundler/rvm? If so, start irb with:

bundle exec irb
nattfodd
  • 1,790
  • 1
  • 17
  • 35
0

make sure you are in the right gemset and ruby version from where you are accessing the gem. Before typing in the irb, check what gemset you are in:

rvm gemset list

then check the gems installed in that particular gemset

rvm <my-gemset-name> do gem list

If they do not match, that is your problem and you can fix it by changing to the right gemset:

 rvm use <my-gemset>

Similarly, check for ruby version, i.e if the ruby version for your installed gem and from where you are running your irb match

slal
  • 2,657
  • 18
  • 29