Reputation: 3588
I'm unable to have rails recognize the mysql2 gem that I've installed. I'm using rails 3.1 and ruby 1.9.2. I'm stumped here..
dan@luci:~$ cd snorby/
Using: /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby
dan@luci:~/snorby$ gem list -l | grep mysql2
mysql2 (0.3.11)
dan@luci:~/snorby$ rails c
Loading development environment (Rails 3.1.0)
1.9.2p290 :001 > require 'mysql2'
LoadError: no such file to load -- mysql2
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from (irb):1
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
from /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
dan@luci:~/snorby$ echo $GEM_PATH
/home/dan/.rvm/gems/ruby-1.9.2-p290@snorby:/home/dan/.rvm/gems/ruby-1.9.2-p290@global
dan@luci:~/snorby$ ls -l /home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/gems/mysql2-0.3.11/
total 68
drwxr-xr-x 2 dan dan 4096 2012-08-17 14:22 benchmark
-rw-r--r-- 1 dan dan 12460 2012-08-17 14:22 CHANGELOG.md
drwxr-xr-x 2 dan dan 4096 2012-08-17 14:22 examples
drwxr-xr-x 3 dan dan 4096 2012-08-17 14:22 ext
-rw-r--r-- 1 dan dan 25 2012-08-17 14:22 Gemfile
drwxr-xr-x 3 dan dan 4096 2012-08-17 14:22 lib
-rw-r--r-- 1 dan dan 1090 2012-08-17 14:22 MIT-LICENSE
-rw-r--r-- 1 dan dan 1099 2012-08-17 14:22 mysql2.gemspec
-rw-r--r-- 1 dan dan 99 2012-08-17 14:22 Rakefile
-rw-r--r-- 1 dan dan 11978 2012-08-17 14:22 README.md
drwxr-xr-x 4 dan dan 4096 2012-08-17 14:22 spec
drwxr-xr-x 2 dan dan 4096 2012-08-17 14:22 tasks
dan@luci:~/snorby$ rvm info
ruby-1.9.2-p290@snorby:
system:
uname: "Linux luci 2.6.32-37-powerpc #81-Ubuntu Fri Dec 2 21:46:08 UTC 2011 ppc GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.1.5(1)-release (powerpc-unknown-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.10.0 by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.beginrescueend.com/]"
updated: "7 months 10 days 23 hours 13 minutes 10 seconds ago"
ruby:
interpreter: "ruby"
version: "1.9.2p290"
date: "2011-07-09"
platform: "powerpc-linux"
patchlevel: "2011-07-09 revision 32553"
full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [powerpc-linux]"
homes:
gem: "/home/dan/.rvm/gems/ruby-1.9.2-p290@snorby"
ruby: "/home/dan/.rvm/rubies/ruby-1.9.2-p290"
binaries:
ruby: "/home/dan/.rvm/rubies/ruby-1.9.2-p290/bin/ruby"
irb: "/home/dan/.rvm/rubies/ruby-1.9.2-p290/bin/irb"
gem: "/home/dan/.rvm/rubies/ruby-1.9.2-p290/bin/gem"
rake: "/home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/bin/rake"
environment:
PATH: "/home/dan/.rvm/gems/ruby-1.9.2-p290@snorby/bin:/home/dan/.rvm/gems/ruby-1.9.2-p290@global/bin:/home/dan/.rvm/rubies/ruby-1.9.2-p290/bin:/home/dan/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
GEM_HOME: "/home/dan/.rvm/gems/ruby-1.9.2-p290@snorby"
GEM_PATH: "/home/dan/.rvm/gems/ruby-1.9.2-p290@snorby:/home/dan/.rvm/gems/ruby-1.9.2-p290@global"
MY_RUBY_HOME: "/home/dan/.rvm/rubies/ruby-1.9.2-p290"
IRBRC: "/home/dan/.rvm/rubies/ruby-1.9.2-p290/.irbrc"
RUBYOPT: ""
gemset: "snorby"
dan@luci:~/snorby$ bundle exec gem list -l | grep mysql2
dan@luci:~/snorby$ echo $?
1
Upvotes: 0
Views: 291
Reputation: 53178
Rails will automatically use Bundler.setup
when starting, it is equivalent with bundle exec
from command line, to allow loading mysql gem you need it to your Gemfile
and run bundle install
, best if you place it in proper group - some projects use pg for production and mysql for development, if you plan always using it then it can be specified without group.
Upvotes: 1