heroku / legacy-cli

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

undefined method `[]' for nil:NilClass (NoMethodError) #831

Open dennismonsewicz opened 11 years ago

dennismonsewicz commented 11 years ago

I recently tried to run the heroku fork command via the heroku toolbelt, but when I did, I ran into this issue:

undefined method `[]' for nil:NilClass (NoMethodError)
/Users/dennismonsewicz/.heroku/client/lib/heroku/command/fork.rb:57:in `block in index'
/Users/dennismonsewicz/.heroku/client/lib/heroku/command/fork.rb:45:in `each'
/Users/dennismonsewicz/.heroku/client/lib/heroku/command/fork.rb:45:in `index'
/Users/dennismonsewicz/.heroku/client/lib/heroku/command.rb:206:in `run'
/Users/dennismonsewicz/.heroku/client/lib/heroku/cli.rb:28:in `start'
/usr/bin/heroku:24:in `<main>'

Command: heroku fork staging-2-0-recruittalk --app=staging-recruittalk Version: heroku-toolbelt/2.39.4 (x86_64-darwin10.8.0) ruby/1.9.3

rubydubee commented 11 years ago

FYI worked for me with a slightly older version: Command: heroku fork night-fjord-2016 --app morning-fjord-2016 Version: heroku-toolbelt/2.39.0 (x86_64-darwin10.8.0) ruby/1.9.3

rwdaigle commented 11 years ago

@dennismonsewicz this appears to occur when the provisioning of a new Heroku Postgres database fails (the target add-on doesn't exist, but the forking process still continues.

If you try it again, does it still fail, and if so can you paste the full output of the command?

ryankee commented 11 years ago

I can back this issue up. As @rwdaigle points out, the error is thrown when the PG database provisioning fails. Here's the full dump:

$ heroku fork -a edited_existing_app_name edited_target_app_name
Creating fork edited_target_app_name... done
Copying slug... done
Adding memcachier:dev... done
Adding newrelic:standard... done
Adding pgbackups:auto-month... done
Adding heroku-postgresql:crane... skipped (Could not communicate with vendor, please try again later)
 !    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 `[]' for nil:NilClass (NoMethodError)
    Backtrace:   /Users/ryankee/.heroku/client/lib/heroku/command/fork.rb:57:in `block in index'
                 /Users/ryankee/.heroku/client/lib/heroku/command/fork.rb:45:in `each'
                 /Users/ryankee/.heroku/client/lib/heroku/command/fork.rb:45:in `index'
                 /Users/ryankee/.heroku/client/lib/heroku/command.rb:206:in `run'
                 /Users/ryankee/.heroku/client/lib/heroku/cli.rb:28:in `start'
                 /usr/local/heroku/bin/heroku:24:in `<main>'

    Command:     heroku fork -a edited_existing_app_name edited_target_app_name
    Plugins:     heroku-config
    Version:     heroku-toolbelt/2.39.4 (x86_64-darwin10.8.0) ruby/1.9.3

Repeating the command shows the app has already been created:

$ heroku fork -a edited_existing_app_name edited_target_app_name
Creating fork edited_target_app_name... failed
 !    Name is already taken
julkiewicz commented 10 years ago

I can confirm this issue.

julkiewicz commented 10 years ago

Is there any way of downgrading heroku client to an older, working version? The auto update gets in my way.

catsby commented 10 years ago

@julkiewicz not at this time, sorry. Can you share the version of the Toolbelt you're using? The issue above was on much older versions, I'd like to make sure you're seeing this on the latest version (3.2.2). If you can share your recent output that would help (as well as time that this occurred). Thanks!

julkiewicz commented 10 years ago

Yes, I realized that as well. I do use the latest version of the client.

Adding heroku-postgresql:crane... skipped (Could not communicate with vendor, please try again later)
 !    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 `[]' for nil:NilClass (NoMethodError)
Backtrace:   /Users/julk/.heroku/client/lib/heroku/command/fork.rb:64:in `block in index'
             /Users/julk/.heroku/client/lib/heroku/command/fork.rb:52:in `each'
             /Users/julk/.heroku/client/lib/heroku/command/fork.rb:52:in `index'
             /Users/julk/.heroku/client/lib/heroku/command.rb:218:in `run'
             /Users/julk/.heroku/client/lib/heroku/cli.rb:28:in `start'
             /usr/local/heroku/bin/heroku:24:in `<main>'

Command:     heroku fork --app sourceapp destapp --region eu
Version:     heroku-toolbelt/3.2.2 (x86_64-darwin10.8.0) ruby/1.9.3
catsby commented 10 years ago

I do not believe this is an issue with the CLI, at least not directly.

Adding heroku-postgresql:crane... skipped (Could not communicate with vendor, please try again later)

This indicates an issue communicating with Heroku Postgres. It could be on the API side of things, or possibly your internet connection. Can you manually add a database to an application in the eu? Or create a database in the eu region?

$ heroku addons:add heroku-postgresql:crane <app> --region eu

Or just

$ heroku addons:add heroku-postgresql:crane <app>

If the <app> is already in EU.

I have no problems provisioning databases in the eu, and my current fork attempt is now past that point:

$ heroku fork -a <app> eu-<app> --region eu
Creating fork eu-<app>... done
Copying slug... done
Adding pgbackups:auto-week... done
Adding redistogo:nano... done
Adding scheduler:standard... done
Adding heroku-postgresql:crane... done
Waiting for database to be ready (this can take some time)...

It's clear the CLI could fail more gracefully here, but the error above points elsewhere for the true culprit.