From: "Bartosz DziewoƄski" Date: 2011-09-28T01:40:57+09:00 Subject: Re: Ruby mysql gem works but I see an exception when I execute the script with debug option using -d $DEBUG. The debug option simply shows *all* exceptions *ever* raised - even those later rescued. RubyGems works internally by first letting "old" require function do its job, and only when it fails (= raises a LoadError, like the one you're seeing), tries looking for gems. You can try it by running this simple code with and without debug: begin raise rescue end -- Matma Rex 2011/9/27 Paul Scholes : > Hello, > > I have got some CGI scripts. I use mysql connection and queries in these > scripts. After seeing some anomalies in the scripts I wanted to execute them > using ruby debug options. Here, below, a small test script that shows the > problem. > > Without debug options, there is nothing, no error, I can connect to database > and run queries but when I use debug option ( -d $DEBUG ) it throws an > exception. Interesting thing is, even there is exception, it works, it > connects to database. > > It is fresh Ubuntu 11.04 install. Details are below. > > Any idea ? What is the problem ? How can I fix it ? > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > *rvm -v:* > rvm 1.8.4 by Wayne E. Seguin (wayneeseguin@gmail.com) [ > https://rvm.beginrescueend.com/] > > *ruby -v:* > ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] > > *gem -v:* > 1.8.10 > > *gem list:* > * LOCAL GEMS * > > mysql (2.8.1) > mysql2 (0.3.7) > rake (0.9.2) > > *ruby dbtest.rb:* > 14701920 > > *ruby -d $DEBUG dbtest.rb:* > Exception `LoadError' at > /home/mehmet/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36 > - no such file to load -- mysql > 11340120 > > *more dbtest.rb:* > #!/home/mehmet/.rvm/rubies/ruby-1.9.2-p290/bin/ruby > > require 'rubygems' > require 'mysql' > > connection = Mysql.new("localhost", "root", "deneme123", "mymarket") > > puts connection.object_id > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Cheers, > > --- >