heroku / legacy-cli

Heroku CLI
https://cli.heroku.com
MIT License
1.37k stars 380 forks source link

pg:copy Error: undefined method `resource_name' for nil:NilClass (NoMethodError) #1863

Open tcox5698 opened 8 years ago

tcox5698 commented 8 years ago

Similar to issue #1837, but the apparent resolution there will not work for me as my postgres databases do not appear to the have the "color" urls associated with them.

It may be that I just have the syntax wrong still.

I am trying to copy the database from one application to another. These are test apps - so I have not left them lying around. They were created with heroku apps:create and the hobby-dev postgres database addon.

Thanks.

 !    Heroku client internal error.
 !    Search for help at: https://help.heroku.com
 !    Or report a bug at: https://github.com/heroku/heroku/issues/new

    Error:       undefined method `resource_name' for nil:NilClass (NoMethodError)
    Command:     heroku pg:copy postgres://snzaiodracumwc:oDDjy9BV1z6D01LhOW6cLE2ayx@ec2-75-101-143-150.compute-1.amazonaws.com:5432/d6lto4o6njs2o2 postgres://yjzsyetqglxkeg:YdVTWhKCCNXEnTZYGrwXkDSIP5@ec2-75-101-143-150.compute-1.amazonaws.com:5432/d48et7sta7apr9 --app kubedapp2-tcdev-273 --confirm d48et7sta7apr9
    Plugins:     heroku-oauth
    Version:     heroku-toolbelt/3.42.25 (x86_64-darwin10.8.0) ruby/1.9.3
    Error ID:    3a0fcb375b5c413ca619d04b586a0809

Here is the stack trace from my CLI log:

Heroku client internal error.
undefined method `resource_name' for nil:NilClass
/Users/tcdev/.heroku/client/lib/heroku/client/heroku_postgresql.rb:39:in `resource_name'
/Users/tcdev/.heroku/client/lib/heroku/client/heroku_postgresql.rb:139:in `pg_copy'
/Users/tcdev/.heroku/client/lib/heroku/command/pg_backups.rb:48:in `copy'
/Users/tcdev/.heroku/client/lib/heroku/command.rb:212:in `run'
/Users/tcdev/.heroku/client/lib/heroku/cli.rb:30:in `start'
/usr/bin/heroku:24:in `<main>'
jdx commented 8 years ago

actually this usually means you have a ruby that isn't compiled right. Try reinstalling ruby and/or the toolbelt.

tcox5698 commented 8 years ago

Thanks for the response - but I don't believe the installations of Ruby nor the Heroku toolbelt had anything to do with the problem. I tried multiple installations of Ruby. I tried deleting and reinstalling Heroku Toolbelt. I created a new virtual machine with an Ubuntu base box and installed Heroku Toolbelt - all produced the same error about the "undefined method: 'resource_name'.

However, it worked as desired when I changed the command to:

heroku pg:copy postgres://snzaiodracumwc:oDDjy9BV1z6D01LhOW6cLE2ayx@ec2-75-101-143-150.compute-1.amazonaws.com:5432/d6lto4o6njs2o2 DATABASE_URL --app kubedapp2-tcdev-273 --confirm kubedapp2-tcdev-273

The differences being:

  1. The literal DATABASE_URL in place of the url to the target database.
  2. The target app name as the argument to the --confirm parameter.

So while there is a workaround available, I would still consider this a minor defect - at least in the documentation.