Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize': undefined method connect' for PG:Module on OSX #80

Open
nlively opened this issue Sep 2, 2015 · 12 comments
Open

initialize': undefined method connect' for PG:Module on OSX #80

nlively opened this issue Sep 2, 2015 · 12 comments
Labels

Comments

@nlively
Copy link

nlively commented Sep 2, 2015

I'm using ruby 1.9.3-p551 with RVM on an OSX Yosemite installation. Keep running into this error:

WARN: Unresolved specs during Gem::Specification.reset:
      postgres-pr (~> 0.6)
      activerecord (~> 3.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/myself/.rvm/gems/ruby-1.9.3-p551/gems/pg-0.18.2/lib/pg/connection.rb:230: warning: already initialized constant PGconn
/Users/myself/.rvm/gems/ruby-1.9.3-p551/gems/pg-0.18.2/lib/pg/result.rb:26: warning: already initialized constant PGresult
/Users/myself/.rvm/gems/ruby-1.9.3-p551@global/gems/mysqltopostgres-0.2.20/lib/mysql2psql/connection.rb:46:in `initialize': undefined method `connect' for PG:Module (NoMethodError)
    from /Users/myself/.rvm/gems/ruby-1.9.3-p551@global/gems/mysqltopostgres-0.2.20/lib/mysql2psql/postgres_db_writer.rb:12:in `new'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p551@global/gems/mysqltopostgres-0.2.20/lib/mysql2psql/postgres_db_writer.rb:12:in `initialize'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p551@global/gems/mysqltopostgres-0.2.20/lib/mysqltopostgres.rb:49:in `new'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p551@global/gems/mysqltopostgres-0.2.20/lib/mysqltopostgres.rb:49:in `convert'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p551@global/gems/mysqltopostgres-0.2.20/bin/mysqltopostgres:23:in `<top (required)>'
    from /Users/myself/.rvm/rubies/ruby-1.9.3-p551/bin/mysqltopostgres:23:in `load'
    from /Users/myself/.rvm/rubies/ruby-1.9.3-p551/bin/mysqltopostgres:23:in `<main>'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `eval'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `<main>'

Never seen that error before this task I'm doing, and I can't seem to find it referenced online.

@nlively
Copy link
Author

nlively commented Sep 2, 2015

I've been continuing to research this and play around with the code. Seems like the problem goes away when the 'postgres-pr' gem is excluded from the Gemfile. Looks like these gems conflict in their definition of the PG namespace.

@paazmaya
Copy link
Contributor

Can you create a Pull Request with the suggested fix?

@ljlozano
Copy link

+1, OSX, Yosemite, Ruby 2.1.7 / RVM

/Users/liltomato/.rvm/gems/ruby-2.1.7/gems/pg-0.18.4/lib/pg/connection.rb:230: warning: already initialized constant PGconn
/Users/liltomato/.rvm/gems/ruby-2.1.7/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:6: warning: previous definition of PGconn was here
/Users/liltomato/.rvm/gems/ruby-2.1.7/gems/pg-0.18.4/lib/pg/result.rb:26: warning: already initialized constant PGresult
/Users/liltomato/.rvm/gems/ruby-2.1.7/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:69: warning: previous definition of PGresult was here
/Users/liltomato/.rvm/gems/ruby-2.1.7@global/gems/mysqltopostgres-0.3.0/bin/mysqltopostgres:30:in `<top (required)>': '' does not exist (RuntimeError)
    from /Users/liltomato/.rvm/rubies/ruby-2.1.7/bin/mysqltopostgres:23:in `load'
    from /Users/liltomato/.rvm/rubies/ruby-2.1.7/bin/mysqltopostgres:23:in `<main>'
    from /Users/liltomato/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `eval'
    from /Users/liltomato/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `<main>'

@ideaoforder
Copy link

+1

@guillosaracco
Copy link

+1, OSX, Yosemite, Ruby 2.1.7 / RVM

Any updates on this?

WARN: Unresolved specs during Gem::Specification.reset:
      test-unit (~> 2.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/Guillo/.rvm/gems/ruby-2.1.7/gems/pg-0.18.4/lib/pg/connection.rb:230: warning: already initialized constant PGconn
/Users/Guillo/.rvm/gems/ruby-2.1.7/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:6: warning: previous definition of PGconn was here
/Users/Guillo/.rvm/gems/ruby-2.1.7/gems/pg-0.18.4/lib/pg/result.rb:26: warning: already initialized constant PGresult
/Users/Guillo/.rvm/gems/ruby-2.1.7/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:69: warning: previous definition of PGresult was here
/Users/Guillo/.rvm/gems/ruby-2.1.7@global/gems/mysqltopostgres-0.3.0/bin/mysqltopostgres:30:in `<top (required)>': '' does not exist (RuntimeError)
    from /Users/Guillo/.rvm/rubies/ruby-2.1.7/bin/mysqltopostgres:23:in `load'
    from /Users/Guillo/.rvm/rubies/ruby-2.1.7/bin/mysqltopostgres:23:in `<main>'
    from /Users/Guillo/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `eval'
    from /Users/Guillo/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `<main>'

@nitsujri
Copy link

+1, thanks for ths repo!

@samstickland
Copy link

I have a very similar issue on El Capitan

$ mysqltopostgres
/Users/samuelstickland/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4/lib/pg/connection.rb:230: warning: already initialized constant PGconn
/Users/samuelstickland/.rvm/gems/ruby-2.3.0/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:6: warning: previous definition of PGconn was here
/Users/samuelstickland/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4/lib/pg/result.rb:26: warning: already initialized constant PGresult
/Users/samuelstickland/.rvm/gems/ruby-2.3.0/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:69: warning: previous definition of PGresult was here
/Users/samuelstickland/.rvm/gems/ruby-2.3.0/gems/mysqltopostgres-0.3.0/bin/mysqltopostgres:30:in `<top (required)>': '' does not exist (RuntimeError)
    from /Users/samuelstickland/.rvm/gems/ruby-2.3.0/bin/mysqltopostgres:23:in `load'
    from /Users/samuelstickland/.rvm/gems/ruby-2.3.0/bin/mysqltopostgres:23:in `<main>'
    from /Users/samuelstickland/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/samuelstickland/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

@lucandrade
Copy link

Same here

$ mysqltopostgres
/Library/Ruby/Gems/2.0.0/gems/pg-0.18.4/lib/pg/connection.rb:230: warning: already initialized constant PGconn
/Library/Ruby/Gems/2.0.0/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:6: warning: previous definition of PGconn was here
/Library/Ruby/Gems/2.0.0/gems/pg-0.18.4/lib/pg/result.rb:26: warning: already initialized constant PGresult
/Library/Ruby/Gems/2.0.0/gems/postgres-pr-0.7.0/lib/postgres-pr/postgres-compat.rb:69: warning: previous definition of PGresult was here
/Library/Ruby/Gems/2.0.0/gems/mysqltopostgres-0.3.0/bin/mysqltopostgres:30:in `<top (required)>': '' does not exist (RuntimeError)
    from /usr/local/bin/mysqltopostgres:23:in `load'
    from /usr/local/bin/mysqltopostgres:23:in `<main>'

@eniacization
Copy link

I get the same error as lucandrade.

@paazmaya
Copy link
Contributor

All I can say is that Pull Requests are more than welcome, as I do not have the resources for doing this at the moment

@paazmaya paazmaya added the bug label Aug 21, 2016
@ritec
Copy link

ritec commented Aug 22, 2016

Did anyone ever figure this out? Getting same error as @lucandrade

brettimus pushed a commit to brettimus/mysql2postgres that referenced this issue Oct 1, 2016
This dependency is only used if RUBY_ENVIRONMENT=="JAVA",
which is not the case for me.
@brettimus
Copy link

brettimus commented Oct 1, 2016

I followed the advice of removing references to the postgres-pr gem, since I'm using MRI. (This fix won't work for JRUBY users, sowwy.)

See: https://github.com/brettimus/mysql2postgres/tree/issue_80_workaround

After hitting issue #73, was able to get it to work. (This comment had the fix that did the trick for me.)

Worth noting: if you run the command from your terminal, the "environment" defaults to "development". I.e., the script will try to access the postgres database defined under the development key in your config file. If you want to change that, you should specify a RAILS_ENV variable.

E.g., running

RAILS_ENV=production mysqltopostgres config.yml

Would use the "production" database defined below:

mysql2psql:
  mysql:
    <<: *pii

  destination:
    production:
      <<: *production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests