dblock / slack-gamebot

Ping pong, chess, pool and other games bot for Slack.
MIT License
129 stars 103 forks source link

no method "each" on nil:NilClass - Fresh heroku deploy #158

Closed ScottBarkman closed 6 years ago

ScottBarkman commented 6 years ago

Seems like the bot fails to initialize on a fresh "deploy to heroku" installation. I've set the slack api token in heroku but doesn't seem to get past the init.

I feel this may be a stupid issue on my part - anyone else come across this?

dblock commented 6 years ago

Been a while since I deployed this fresh. What's the stack of the error? Maybe https://github.com/dblock/slack-gamebot/blob/master/DEPLOYMENT.md needs some updates?

ScottBarkman commented 6 years ago
2017-10-19T15:38:30.161335+00:00 app[web.1]: Error connecting to MongoDB: undefined method `each' for nil:NilClass

2017-10-19T15:38:30.161620+00:00 app[web.1]: E, [2017-10-19T15:38:30.161539 #6] ERROR -- : Actor crashed!

2017-10-19T15:38:30.161621+00:00 app[web.1]: NoMethodError: undefined method `each' for nil:NilClass

2017-10-19T15:38:30.161622+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongo-2.4.3/lib/mongo/cluster.rb:172:in `initialize'

2017-10-19T15:38:30.161623+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongo-2.4.3/lib/mongo/client.rb:370:in `new'

2017-10-19T15:38:30.161625+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongo-2.4.3/lib/mongo/client.rb:370:in `create_from_addresses'

2017-10-19T15:38:30.161626+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongo-2.4.3/lib/mongo/client.rb:235:in `initialize'

2017-10-19T15:38:30.161627+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.6/lib/mongoid/clients/factory.rb:64:in `new'

2017-10-19T15:38:30.161627+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.6/lib/mongoid/clients/factory.rb:64:in `create_client'

2017-10-19T15:38:30.161628+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.6/lib/mongoid/clients/factory.rb:42:in `default'

2017-10-19T15:38:30.161628+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.6/lib/mongoid/clients.rb:38:in `default'

2017-10-19T15:38:30.161629+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.6/lib/mongoid.rb:65:in `default_client'

2017-10-19T15:38:30.161630+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/slack-ruby-bot-server-0.5.0/lib/slack-ruby-bot-server/app.rb:41:in `check_database!'

2017-10-19T15:38:30.161630+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/slack-ruby-bot-server-0.5.0/lib/slack-ruby-bot-server/app.rb:6:in `prepare!'

2017-10-19T15:38:30.161631+00:00 app[web.1]:    /app/slack-gamebot/app.rb:11:in `prepare!'

2017-10-19T15:38:30.161632+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/calls.rb:28:in `public_send'

2017-10-19T15:38:30.161632+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/calls.rb:28:in `dispatch'

2017-10-19T15:38:30.161633+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/call/sync.rb:16:in `dispatch'

2017-10-19T15:38:30.161633+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/cell.rb:50:in `block in dispatch'

2017-10-19T15:38:30.161634+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/cell.rb:76:in `block in task'

2017-10-19T15:38:30.161635+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/actor.rb:339:in `block in task'

2017-10-19T15:38:30.161635+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/task.rb:44:in `block in initialize'

2017-10-19T15:38:30.161636+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/celluloid-0.17.3/lib/celluloid/task/fibered.rb:14:in `block in create'
ScottBarkman commented 6 years ago

I tried the Deploy button in the development.md as well as creating the app first on heroku and using their CLI to deploy a forked git thinking I may needed to have the slack bot token environment variable set before I deployed for the first time - and both amounted to that error

My guess is some dependency is outdated but I am definitely no ruby guy ;)

dblock commented 6 years ago

This looks like some MongoDB setting is not there, not properly checked or the mongolab addon is not present. So

1) Is there a MongoLab addon setup? It's declared in the app.json so that should have added itself. 2) Is there any of these configured on the app: ENV['MONGO_URL'] || ENV['MONGOHQ_URI'] || ENV['MONGOLAB_URI'] || ENV['MONGODB_URI']? I am going to guess that https://github.com/dblock/slack-gamebot/blob/master/config/mongoid.yml#L24 is missing MONGO_URL and that's what's configured? In which case, make a PR?