Subsecciones

Troubleshooting

Crashing

If you push your app and it crashes, heroku ps shows state crashed:
=== web (1X): `bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT`
web.1: crashed 2013/10/24 20:21:34 (~ 1h ago)
check your logs to find out what went wrong.

Here are some common problems.

Failed to require a sourcefile

If your app failed to require a sourcefile, chances are good you’re running Ruby 1.9.1 or 1.8 in your local environment.

The load paths have changed in Ruby 1.9 which applies to Ruby 2.0.

Port your app forward to Ruby 2.0.0 making certain it works locally before trying to push to Cedar again.

Encoding error

Ruby 1.9 added more sophisticated encoding support to the language which applies to Ruby 2.0.

Not all gems work with Ruby 2.0. If you hit an encoding error, you probably haven’t fully tested your app with Ruby 2.0.0 in your local environment.

Port your app forward to Ruby 2.0.0 making certain it works locally before trying to push to Cedar again.

Missing a gem

If your app crashes due to missing a gem, you may have it installed locally but not specified in your Gemfile.

You must isolate all local testing using bundle exec.

For example, don’t run ruby web.rb, run

bundle exec ruby web.rb
Don’t run rake db:migrate, run
bundle exec rake db:migrate.
Another approach is to create a blank RVM gemset to be absolutely sure you’re not touching any system-installed gems:
$ rvm gemset create myapp
$ rvm gemset use myapp

Runtime dependencies on development/test gems

If you’re still missing a gem when you deploy, check your Bundler groups.

Heroku builds your app without the development or test groups, and if you app depends on a gem from one of these groups to run, you should move it out of the group.

One common example using the RSpec tasks in your Rakefile. If you see this in your Heroku deploy:

$ heroku run rake -T
Running `rake -T` attached to terminal... up, ps.3
rake aborted!
no such file to load -- rspec/core/rake_task
Then you’ve hit this problem.

First, duplicate the problem locally like so:

$ bundle install --without development:test
...
$ bundle exec rake -T
rake aborted!
no such file to load -- rspec/core/rake_task
Now you can fix it by making these Rake tasks conditional on the gem load. For example:
begin
  require "rspec/core/rake_task"

  desc "Run all examples"
  RSpec::Core::RakeTask.new(:spec) do |t|
    t.rspec_opts = %w[--color]
    t.pattern = 'spec/*_spec.rb'
  end
rescue LoadError
end
Confirm it works locally, then push to Heroku.

Versiones soportadas por Heroku

Véase Heroku Ruby Support

Rack::Sendfile

Heroku does not support the use of Rack::Sendfile.

Rack:Sendfile usually requires that there is a frontend webserver like nginx or apache is running on the same machine as the application server.

This is not how Heroku is architected. Using the Rack::Sendfile middleware will cause your file downloads to fail since it will send a body with Content-Length of 0.

heroku run: Timeout awaiting process

The heroku run command opens a connection to Heroku on port 5000. If your local network or ISP is blocking port 5000 (el caso de la ULL), or you are experiencing a connectivity issue, you will see an error similar to:

[~/srcPLgrado/pegjscalc(master)]$ heroku run console
Running `console` attached to terminal... up, run.4357
 !    
 !    Timeout awaiting process

You can test your connection to Heroku by trying to connect directly to port 5000 by using telnet to rendezvous.runtime.heroku.com.

Desde la universidad fracasa:

[~/srcPLgrado/pegjscalc(master)]$ telnet rendezvous.runtime.heroku.com 5000Trying 50.19.103.36...
telnet: connect to address 50.19.103.36: Operation timed out
telnet: Unable to connect to remote host

A successful session will look like this:

$ telnet rendezvous.runtime.heroku.com 5000
Trying 50.19.103.36...
Connected to ec2-50-19-103-36.compute-1.amazonaws.com.
Escape character is '^]'.
If you do not get this output, your computer is being blocked from accessing our services. We recommend contacting your IT department, ISP, or firewall manufacturer to move forward with this issue.

Casiano Rodríguez León
2015-01-25