<< | Index | >>
suspend
Check gem (pg, dbi)
masa@masa ~ $ gem search dbi *** LOCAL GEMS *** masa@masa ~ $ gem search pg *** LOCAL GEMS *** pg (0.8.0)
Check emerge (pg, dbi)
masa@masa ~ $ emerge -s dbi * dev-ruby/ruby-dbi Latest version available: 0.2.0-r1 Latest version installed: 0.2.0-r1 Size of files: 97 kB Homepage: http://ruby-dbi.rubyforge.org Description: Ruby/DBI - a database independent interface for accessing databases - similar to Perl's DBI License: BSD masa@masa ~ $ emerge -s pg * dev-ruby/pg Latest version available: 0.10.0 Latest version installed: 0.9.0-r1 Size of files: 110 kB Homepage: http://bitbucket.org/ged/ruby-pg/ Description: Ruby extension library providing an API to PostgreSQL License: || ( GPL-2 Ruby )
Note
Check oddb.org working
Result
Uninstall 'pg' through emerge
masa@masa ~ $ sudo emerge -C dev-ruby/pg
Check oddb.org
Upgrade pg
masa@masa ~ $ sudo gem install pg ERROR: Error installing pg: pg requires Ruby version >= 1.8.7.
Install gp version 0.9.0
masa@masa ~ $ sudo gem install pg --version "= 0.9.0" Building native extensions. This could take a while... Successfully installed pg-0.9.0 1 gem installed /usr/lib64/ruby/gems/1.8/gems/rdoc-2.5.11/lib/rdoc/ruby_lex.rb:67: warning: parenthesize argument(s) for future version Installing ri documentation for pg-0.9.0... Installing RDoc documentation for pg-0.9.0...
Note
Check oddb.org
Uninstall dbi
masa@masa ~ $ sudo emerge -C ruby-dbi
Check oddb.org
masa@masa ~/ywesee/oddb.org $ ruby bin/oddbd /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- dbi (LoadError) from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/site_ruby/1.8/odba/storage.rb:6 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/site_ruby/1.8/odba.rb:61 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:4 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from bin/oddbd:9
Note
Install the latest dbi through gem
masa@masa ~ $ sudo gem install dbi Successfully installed deprecated-2.0.1 Successfully installed dbi-0.4.5 2 gems installed /usr/lib64/ruby/gems/1.8/gems/rdoc-2.5.11/lib/rdoc/ruby_lex.rb:67: warning: parenthesize argument(s) for future version Installing ri documentation for deprecated-2.0.1... Installing ri documentation for dbi-0.4.5... Installing RDoc documentation for deprecated-2.0.1... Installing RDoc documentation for dbi-0.4.5...
Note
Check oddb.org
/usr/lib64/ruby/gems/1.8/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `instance_method': {:metaclass=>:singleton_class} is not a symbol (TypeError) from /usr/lib64/ruby/gems/1.8/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `deprecate' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb:13 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object.rb:5 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8 ... 10 levels... from /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:26 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from bin/oddbd:9
Uninstall deprecated
masa@masa ~ $ sudo gem uninstall deprecated You have requested to uninstall the gem: deprecated-2.0.1 dbi-0.4.5 depends on [deprecated (= 2.0.1)] If you remove this gems, one or more dependencies will not be met. Continue with Uninstall? [Yn] Y Successfully uninstalled deprecated-2.0.1
Check oddb.org
masa@masa ~/ywesee/oddb.org $ ruby bin/oddbd /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem deprecated (= 2.0.1) (Gem::LoadError) from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:214:in `activate' from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:249:in `activate' from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:248:in `each' from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:248:in `activate' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require' from /usr/lib64/ruby/site_ruby/1.8/odba/storage.rb:6 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/site_ruby/1.8/odba.rb:61 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:4 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from bin/oddbd:9
Uninstall dbi from gem
masa@masa ~ $ sudo gem uninstall dbi Remove executables: dbi, test_broken_dbi in addition to the gem? [Yn] Y Removing dbi Removing test_broken_dbi Successfully uninstalled dbi-0.4.5
Install ruby-dbi (0.2.0) throuhg emerge again
masa@masa ~ $ sudo emerge ruby-dbi >>> Installing (1 of 2) dev-ruby/ruby-postgres-0.7.9.20080128-r1 >>> Installing (2 of 2) dev-ruby/ruby-dbi-0.2.0-r1
Note
Check oddb.org
Uninstall ruby-postgres from emerge
masa@masa ~ $ sudo emerge -C ruby-postgres
Check oddb.org
'pg' version 0.9.0 can work
'dbi' version 0.2.0 is at the moment required
Current condition
Trace error message
/usr/lib64/ruby/gems/1.8/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `instance_method': {:metaclass=>:singleton_class} is not a symbol (TypeError) from /usr/lib64/ruby/gems/1.8/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `deprecate' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb:13 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object.rb:5 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8 ... 10 levels... from /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:26 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from bin/oddbd:9
Look at the hidden error messages
/home/masa/ywesee/oddb.org/src/util/oddbapp.rb:26
begin require 'paypal' rescue => e puts e.backtrace exit end
Result
/usr/lib64/ruby/gems/1.8/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `instance_method' /usr/lib64/ruby/gems/1.8/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `deprecate' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb:13 /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object.rb:5 /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8 /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8:in `each' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8 /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support.rb:56 /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' /usr/lib64/ruby/gems/1.8/gems/paypal-2.0.0/lib/paypal.rb:27 /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:27 /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' bin/oddbd:9
Question
Check /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb
require 'active_support/deprecation' class Object # Get object's meta (ghost, eigenclass, singleton) class. # # Deprecated in favor of Object#singleton_class. def metaclass class << self self end end deprecate :metaclass => :singleton_class end
Note
Consideration
Experiment
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/deprecation.rb
def deprecate(*method_names) options = method_names.extract_options! method_names = method_names + options.keys method_names.each do |method_name| alias_method_chain(method_name, :deprecation) do |target, punctuation| class_eval(<<-EOS, __FILE__, __LINE__ + 1) def #{target}_with_deprecation#{punctuation}(*args, &block) # def generate_secret_with_deprecation(*args, &block) ::ActiveSupport::Deprecation.warn( # ::ActiveSupport::Deprecation.warn( self.class.deprecated_method_warning( # self.class.deprecated_method_warning( :#{method_name}, # :generate_secret, #{options[method_name].inspect}), # "You should use ActiveSupport::SecureRandom.hex(64)"), caller # caller ) # ) send(:#{target}_without_deprecation#{punctuation}, *args, &block) # send(:generate_secret_without_deprecation, *args, &block) end # end EOS end end end
and then add
alias :masa :deprecate
to the last line of
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/deprecation.rb
further also add
masa :metaclass => :singleton_class
#deprecate :metaclass => :singleton_class
to
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb
Result
masa@masa ~/ywesee/oddb.org $ bin/oddbd /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:300:in `load_driver': Unable to load driver 'Pg' (underlying error: uninitialized constant DBI::DBD::Pg) (DBI::InterfaceError) from /usr/lib64/ruby/1.8/monitor.rb:242:in `synchronize' from /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver' from /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver' from /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:60:in `_connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:59:in `times' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:59:in `_connect' from /usr/lib64/ruby/site_ruby/1.8/odba/connection_pool.rb:56:in `connect' ... 7 levels... from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require' from bin/oddbd:10
Note
'deprecate' method is used and defined in 'activesupport' library, but also 'deprecate' method is defined in 'deprecated' library with a different meaning. 'activesupport' tries to call 'deprecate' method from 'deprecated' library. This is the cause of error.
Check dbd-pg version on gem
masa@masa ~/ywesee/oddb.org $ gem search dbd-pg -ra *** REMOTE GEMS *** dbd-pg (0.3.9, 0.3.8, 0.3.7, 0.3.6, 0.3.5, 0.3.4, 0.3.3)
Install dbd-pg version 0.3.9
masa@masa ~/ywesee/oddb.org $ sudo gem install dbd-pg
Check oddb.org
It works!!
Memo
masa@masa ~/ywesee/oddb.org $ sudo gem uninstall pg You have requested to uninstall the gem: pg-0.9.0 dbd-pg-0.3.9 depends on [pg (>= 0)]
Check the installed libraries
* dev-ruby/ruby-dbi Latest version available: 0.2.0-r1 Latest version installed: [ Not Installed ] Size of files: 97 kB Homepage: http://ruby-dbi.rubyforge.org Description: Ruby/DBI - a database independent interface for accessing databases - similar to Perl's DBI License: BSD * dev-ruby/ruby-postgres Latest version available: 0.7.9.20080128-r1 Latest version installed: [ Not Installed ] Size of files: 32 kB Homepage: http://ruby.scripting.ca/postgres Description: An extension library to access a PostgreSQL database from Ruby License: GPL-2 Ruby * dev-ruby/dbd-pg Latest version available: 0.3.9 Latest version installed: [ Not Installed ] Size of files: 63 kB Homepage: http://ruby-dbi.rubyforge.org Description: The PostgreSQL database driver (DBD) for Ruby/DBI License: BSD * dev-ruby/pg Latest version available: 0.10.0 Latest version installed: [ Not Installed ] Size of files: 110 kB Homepage: http://bitbucket.org/ged/ruby-pg/ Description: Ruby extension library providing an API to PostgreSQL License: || ( GPL-2 Ruby )
Note
masa@masa ~/ywesee/oddb.org $ gem list *** LOCAL GEMS *** activesupport (2.3.8) dbd-pg (0.3.9) dbi (0.4.5) deprecated (2.0.1) pg (0.9.0)
Note
Result
Memo
dbi and pg test by using a simple script
dbi_test.rb
require 'dbi' begin print "Available drivers=" p DBI.available_drivers # connection to database dbh = DBI.connect("dbi:pg:testdb:localhost", "masa", "") # get server version string row = dbh.select_one("select version()") puts "Server version: " + row[0] rescue DBI::DatabaseError => e puts "An error occurred" puts "Error code: #{e.err}" puts "Error message: #{e.errstr}" ensure # disconnect dbh.disconnect if dbh end
Check libraries
Result
masa@masa ~/work $ ruby dbi_test.rb Available drivers=["dbi:SQLRelay:", "dbi:Proxy:", "dbi:Pg:"] Server version: PostgreSQL 8.4.2 on x86_64-pc-linux-gnu, compiled by GCC x86_64-pc-linux-gnu-gcc (Gentoo 4.4.3 p1.0) 4.4.3, 64-bit
Uninstall
Install
Result
masa@masa ~/work $ ruby dbi_test.rb Available drivers=[] /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:300:in `load_driver': Unable to load driver 'pg' (underlying error: wrong constant name pg) (DBI::InterfaceError) from /usr/lib64/ruby/1.8/monitor.rb:242:in `synchronize' from /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver' from /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver' from /usr/lib64/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect' from dbi_test2.rb:11
Uninstall
Install
Uninstall
Now
* dev-ruby/dbd-pg Latest version available: 0.3.9 Latest version installed: 0.3.9 Size of files: 63 kB Homepage: http://ruby-dbi.rubyforge.org Description: The PostgreSQL database driver (DBD) for Ruby/DBI License: BSD * dev-ruby/pg Latest version available: 0.10.0 Latest version installed: [ Not Installed ] Size of files: 110 kB Homepage: http://bitbucket.org/ged/ruby-pg/ Description: Ruby extension library providing an API to PostgreSQL License: || ( GPL-2 Ruby ) * dev-ruby/ruby-dbi Latest version available: 0.4.3 Latest version installed: 0.4.3 Size of files: 79 kB Homepage: http://ruby-dbi.rubyforge.org Description: Ruby/DBI - a database independent interface for accessing databases - similar to Perl's DBI License: BSD
masa@masa ~/work $ gem list deprecated (2.0.1) pg (0.9.0)
Note
Result
masa@masa ~/work $ ruby dbi_test.rb Available drivers=["dbi:Pg:"] Server version: PostgreSQL 8.4.2 on x86_64-pc-linux-gnu, compiled by GCC x86_64-pc-linux-gnu-gcc (Gentoo 4.4.3 p1.0) 4.4.3, 64-bit
Note
Check the current condition of my Windows7
looks running
Server [localhost]: Database [postgres]: Port [5432]: Username [postgres]: Passwort f³r Benutzer postgres: psql (8.4.6) Warnung: Konsolencodeseite (850) unterscheidet sich von der Windows- Codeseite (1252). 8-Bit-Zeichen funktionieren möglicherweise nicht richtig. Einzelheiten finden Sie auf der psql-Handbuchseite unter »Notes for Windows users«. Geben Sie »help« für Hilfe ein. postgres=# \l Liste der Datenbanken Name | Eigent\xFCmer | Kodierung | Sortierfolge | Zeichentyp | Zugriffsprivilegien -----------+---------------+-----------+---------------------+---------------------+----------------------- postgres | postgres | UTF8 | German, Switzerland | German, Switzerland | template0 | postgres | UTF8 | German, Switzerland | German, Switzerland | =c/postgres : postgres=CTc/postgres template1 | postgres | UTF8 | German, Switzerland | German, Switzerland | =c/postgres : postgres=CTc/postgres (3 Zeilen) postgres=#
Test dbi script
C:\Users\masa>gem list *** LOCAL GEMS *** dbd-pg (0.3.9) dbi (0.4.5) deprecated (2.0.1) pg (0.9.0 x86-mingw32)
C:\Users\masa>type test.rb require 'dbi' begin print "Available drivers=" p DBI.available_drivers # connection to database dbh = DBI.connect("dbi:pg:testdb:localhost", "masa", "") # get server version string row = dbh.select_one("select version()") puts "Server version: " + row[0] rescue DBI::DatabaseError => e puts "An error occurred" puts "Error code: #{e.err}" puts "Error message: #{e.errstr}" ensure # disconnect dbh.disconnect if dbh end
Result
C:\Users\masa>ruby -rubygems test.rb Available drivers=[] An error occurred Error code: Error message: fe_sendauth: no password supplied
Note
Experiment
test.rb
require 'rubygems' require 'dbi' begin print "Available drivers=" p DBI.available_drivers # connection to database dbh = DBI.connect("dbi:pg:postgres:localhost", "postgres", "xxx") #dbh = DBI.connect("dbi:pg:testdb:localhost", "masa", "") # get server version string row = dbh.select_one("select version()") puts "Server version: " + row[0] rescue DBI::DatabaseError => e puts "An error occurred" puts "Error code: #{e.err}" puts "Error message: #{e.errstr}" ensure # disconnect dbh.disconnect if dbh end
Result
C:\Users\masa>ruby test.rb Available drivers=[] Server version: PostgreSQL 8.4.6, compiled by Visual C++ build 1400, 32-bit
Note
gem list
C:\Users\masa>gem list *** LOCAL GEMS *** dbd-pg (0.3.9) dbi (0.4.5) deprecated (2.0.1) pg (0.9.0 x86-mingw32)
Ruby version
C:\Users\masa>ruby -v ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
Experiment (create a new database)
Re-install PostgreSQL 8.4
Point
Reference
Check test.rb
C:\Users\masa>ruby test.rb Available drivers=[] Server version: PostgreSQL 8.4.6, compiled by Visual C++ build 1400, 32-bit