Crash when querying on ruby 2.0.0-p0

Issue #154 invalid
created an issue

Hello, this is on Ruby 2.0.0-p0 running on OS X (installed via homebrew).

irb(main):001:0> require 'pg'
=> true
# FYI,  PG::VERSION == "0.14.1"
irb(main):002:0> conn = PGconn.connect("localhost", 5432, "", "", "mydb")
=> #<PG::Connection:0x007ff5c9fc98f8>
irb(main):003:0> conn.exec("select 1")
TypeError: wrong argument type nil (expected Array)
    from (irb):3:in `exec'
    from (irb):3
    from /Users/jonas/.rbenv/versions/2.0.0-p0/bin/irb:12:in `<main>'

Same code works on 1.9.3. Any idea what might be wrong there?

Comments (5)

  1. Michael Granger repo owner

    I can't reproduce this:

    $ ruby -ve "require 'pg'; c = PG.connect(dbname: 'test'); p c.exec('select 1'); p PG::VERSION"
    ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1]
    #<PG::Result:0x007fdce90b6df0 @connection=#<PG::Connection:0x007fdce90b74d0>>

    I also added Ruby 2.0.0p0 to the Travis build last week, and it's been passing there, albeit with the upcoming 0.15.0, not 0.14.1.

    What does running the same thing (with your database name, naturally) show you? If you still get an error, try running it with -vde instead of -ve, and see if there's any warnings or anything? I'm at a bit of a loss.

  2. jonasschneider reporter

    Oh, I figured it out. Actually, it was an issue with bundler: When bundler detects that you changed the ruby version in your Gemfile, it discards all installed gems (including compiled ext's). However, I added the "ruby '2.0.0'" line to my Gemfile without having specified a ruby version before. Therefore Bundler didn't clean its cache, and that presumably caused the breakage because of ABI incompatibilities. Doing that manually and reinstalling the gem fixed it. Thanks for your time.

  3. Log in to comment