0

I'm trying to migrate my Rails apps to PostGreSql in order to work in the same environnement as on heroku...

I installed postgres, pg, and postgres-pr fine on my mac but I can't get Taps to pull my databases off from Heroku to my postgresql server.

My Rails Apps connect seamlessly to the database.

When I run into the irb this is what I get:

>> require "rubygems"
=> false
>> require "sequel"
=> true
>> DB = Sequel.postgres
NameError: uninitialized constant Sequel::Postgres::PGError
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/adapters/postgres.rb:89
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `k_require'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:249:in `tsk_require'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:72:in `check_requiring_thread'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:69:in `synchronize'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:69:in `check_requiring_thread'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:249:in `tsk_require'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/database/connecting.rb:25:in `adapter_class'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/database/connecting.rb:63:in `connect'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:119:in `connect'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:282:in `adapter_method'
    from /Library/Ruby/Gems/1.8/gems/sequel-3.17.0/lib/sequel/core.rb:289:in `postgres'
    from (irb):3
>> 

I don't understand what's going wrong.

Does anybody have an idea?


This is what I get Jeremy

BigMac:~ jp$ ruby -rubygems -rpg -e "p PGError"
ruby: no such file to load -- pg (LoadError)
BigMac:~ jp$ ruby -rubygems -rpostgres -e "p PGError"
ruby: no such file to load -- postgres (LoadError)

I'm not sure to understand what you mean by "Check for a pg.rb or postgres.rb somewhere in your path"

Should I scan all the directories in my $PATH and look for an unwanted pg.rb or postgres.rb file?


That's weird because I did install pg and postgre

Here is what I just ran

BigMac:/ jp$ sudo gem install pg
Password:
Building native extensions.  This could take a while...
Successfully installed pg-0.10.0
1 gem installed
Installing ri documentation for pg-0.10.0...
Installing RDoc documentation for pg-0.10.0...
BigMac:/ jp$ ruby -rubygems -rpg -e "p PGError"
ruby: no such file to load -- pg (LoadError)
BigMac:/ jp$ 
1
  • Please run gem search pg postgres at the command-line and edit your original question, adding the output. If you get no output then it sounds like you need to run gem install pg. Commented Dec 3, 2010 at 20:26

3 Answers 3

3

I was running into the exact same problem trying to run heroku db:pull to my local postgresql database using the pg gem. Randomly ended up fixing the problem by removing the following gems:

activerecord-jdbc-adapter 
activerecord-jdbcpostgresql-adapter

Tried it again after removing those gems and managed to pull from heroku successfully. Try checking your gem file for any gems that relate to postgres other than your pg gem and remove it. All the best

Sign up to request clarification or add additional context in comments.

2 Comments

Hey 2potatocakes, I did a gem update heroku and everything worked fine after that. I'll keep your answer if it starts happening again!
This worked for me too, unbelievable! Nice job @2potatocakes
1

For some reason, whatever postgres or pg file you are requiring does not define the PGError class. Check for a pg.rb or postgres.rb somewhere in your path.

What happens when you ruby the following:

ruby -rubygems -rpg -e "p PGError"
ruby -rubygems -rpostgres -e "p PGError"

Comments

1

If you check out the postgres adapter source code, you can see it attempts to load the pg Ruby gem followed by the postgres gem (prioritized in that order). According to your output of ruby -rubygems -rpg -e "p PGError" You don't have the pg gem, nor do you have the postgres gem installed on your system.

Make sure you run gem install pg and try that line again, if that doesn't work it becomes a Rubygems issue and not a Sequel issue. If you're able to load pg then PGError will be defined.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.