UPDATE
I did the following and this is the callstack I am still getting in the logs:
2012-08-06T12:30:57+00:00 heroku[slugc]: Slug compilation finished
2012-08-06T12:30:58+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RACK_ENV -p 56970`
2012-08-06T12:30:59+00:00 app[web.1]: bash: bundle: command not found
2012-08-06T12:31:00+00:00 heroku[web.1]: Process exited with status 127
2012-08-06T12:31:00+00:00 heroku[web.1]: State changed from starting to crashed
2012-08-06T12:31:08+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-08-06T12:31:08+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
2012-08-06T12:31:09+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-08-06T12:31:10+00:00 heroku[router]: Error H10 (App crashed) -> GET arcane-garden-1058.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
My Procfile file now looks like this:
root: = ::File.dirname(__FILE__)
require: ::File.join( root, 'app' )
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
run: WPL.new
Gemfile looks like this:
source :rubygems
gem 'thin'
gem 'sinatra'
gem 'shotgun'
gem 'sinatra'
gem 'mongo'
gem 'json'
My app.rb looks like this now:
require 'shotgun'
require 'sinatra'
require 'mongo'
require 'json/pure'
class WPL < Sinatra::Application
db = Mongo::Connection.new.db('docs')
get '/' do
File.read(File.join('public', 'index.html'))
end
end
And config.ru looks like this:
require './app'
run WPL.new
So I'm trying to deploy my app and I've run into several issues. Everything works fine locally. I push the app to heroku and everything seems to be ok but when I check the logs it says it cant find command 'bundle'.
This is what my Procfile looks like.
web: bundle exec ruby app.rb -p $PORT
I tried removing bundle exec and just went with ruby app.rb -p $POST got further in the process but more errors.
The next set of errors I get are all gem related. It simply can't find any of the gems that are required. This is what my app.rb looks like.
require 'shotgun'
require 'sinatra'
require 'mongo'
require 'json/pure'
db = Mongo::Connection.new.db('docs')
get '/' do
File.read(File.join('public', 'index.html'))
end
My Gemfile looks like this.
source :rubygems
gem 'sinatra'
gem 'shotgun'
gem 'sinatra'
gem 'mongo'
gem 'json'
My config.ru looks like this.
require './app'
run Sinatra::Application
Running heroku run console also results in this error bundle: command not found
What am I missing?
Your Procfile is not using your config.ru.
For a Sinatra application, I would use a Procfile that looks something like this:
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
This similar question might be some help too.
Not sure what happened but I just deleted my app on heroku and created a new one. Then it worked. I think when I created the app originally, heroku thought the app was a node app because I was missing my Procfile.
Related
How does one get a "hello world" sinatra app to execute on Heroku? Heroku's own sample app fails:
For a brand new heroku app, following Heroku's 3-file "hello world" Sinatra deployment instructions at:
https://devcenter.heroku.com/articles/rack
the build fails with bundler: failed to load command: rackup
I've tried it with both the default stack (heroku-20) and thinking that might be the issue tried it on the heroku-18 stack. Same error.
#config.ru
require './hello'
run Sinatra::Application
and
#hello.rb
require 'sinatra'
get '/' do
"Hello World!"
end
and
#Gemfile
source 'https://rubygems.org'
gem 'sinatra'
Gives:
heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p ${PORT:-5000}`
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: State changed from crashed to starting
app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/3.0.0/bin/rackup)
app[web.1]: /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/handler.rb:45:in `pick': Couldn't find handler for: puma, thin, falcon, webrick. (LoadError)
Despite what the Heroku docs say, the Gemfile also needs a web server.
Adding gem 'puma' to the Gemfile did the trick.
I'm trying to deploy to heroku a modular sinatra app that works fine locally. This is in the heroku logs:
2020-12-28T21:05:15.907560+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 58645`
2020-12-28T21:05:18.738254+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.7.0/bin/rackup)
2020-12-28T21:05:18.738283+00:00 app[web.1]: Gem::Exception: can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
The command bundle exec rackup config.ru -p 58645 runs fine locally.
This is my config.ru
require_relative './config/environment.rb'
use EntreeController
use UserController
run ApplicationController
and environment.rb
APP_ENV = ENV["RACK_ENV"] || "development"
ENV['SINATRA_ENV'] ||= "development"
require 'require_all'
require 'bundler/setup'
Bundler.require(:default, ENV['SINATRA_ENV'])
require_all 'app'
require_all 'app/models'
require_all 'app/helpers'
And the Procfile:
web: bundle exec rackup config.ru -p $PORT
I'll post my solution, if ever someone bumps into the same problem. I had followed the indication on the Rakefile here : https://github.com/sinatra-activerecord/sinatra-activerecord.
One solution was to entirely deleted the Rakefile when deploying to Heroku. The other solution is to put only this in the Rakefile :
require "sinatra/activerecord"
require "sinatra/activerecord/rake"
require "./app" # or whereever your app is
Switching to Bundler 2.1.4 solved the problem in my case.
For the longer run one will have to install bundler 2.1.4 and use it, but for the sake of test I just manually edited that line in Gemfile.lock:
BUNDLED WITH
2.1.4
I was using Ruby 2.7.2 and Bundler 2.2.8 — Heroku buildpack provided Bundler 2.1.4.
Funny that Heroku’s Bundler bugs list had nothing about 2.2.8.
having trouble pushing my sinatra app to heroku based on the current setup. I have looked through all of the docs on heroku to figure this out but alas, i'm without resolution and continue to get the following error. No default language could be detected for this app.
app
--.git
-- public
-- views
- app.rb
- config.ru
- gemfile
- Gemfile.lock
- Procfile
- foo.csv
Procfile
web: bundle exec ruby app.rb -p $PORT
config.ru
require './app'
run Sinatra::Application
Gemfile
source 'https://rubygems.org'
ruby "2.4.0"
gem 'sinatra'
app.rb
require 'rubygems'
require 'sinatra'
require 'csv'
Tilt.register Tilt::ERBTemplate, 'html.erb'
set :public_folder, 'public'
get "/" do
erb :index
end
Update
Still not quite sure what the issue was here. I ended up grabbing the following sinatra/heroku shell from github, and replaced it with the assets from my app. Once I ran a bundle and pushed to heroku everything ended up working. I'm sure the issue is structurally nuanced and can be pulled from a deeper look at the working setup, for now - i'm just happy it's working.
https://github.com/runemadsen/Sinatra-Heroku-Template
I just started a new app on heroku, I used git clone from a running application. I pushed everything up, migrated the db, and restarted heroku. The app still crashes.
heroku logs gives me:
2014-02-27T01:18:25.726069+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=********.herokuapp.com request_id=1ded5a34-7d01-440b-9fb4-0041fdc64715 fwd="75.149.130.1" dyno= connect= service= status=503 bytes=
code=H10 is an "app or dyno crash". The app is running on Thin if that helps.
How do I restart dynos? What can I do to get some more diagnostic info on this?
edit: (more info)
I ran heroku restart thin and immediately ran heroku logs which uncovered this:
ruby: symbol lookup error: /app/vendor/bundle/ruby/2.0.0/gems/eventmachine-1.0.0/lib/rubyeventmachine.so: undefined symbol: rb_enable_interrupt
The app is built on ruby 1.9.2 and rails 3.0.10 so I would assume there is some kind of version issue going on here, but I don't understand it.
This article mentions the same problem with Thin, and recomends not using it. But I have the EXACT same app running fine as another heroku app, and all I've ever used is thin, I really have no idea why this isn't working.
edit 2:
It looks like although my app is built with ruby 1.9.2, heroku is trying to deploy it with ruby 2.0.0. How do I tell it to use 1.9.2? Something in set-up or in my gem/config files?
edit 3: (I think I'm on to something)
running ruby -v yields 1.9.2
running `heroku run "ruby -v" yields 2.0.0
This article says it can be declared in the gemfile. I have a feeling this will fix my problem.
The Heroku ruby buildpack will install the ruby version specified in your Gemfile. Ruby 2.0.0 is the current default ruby.
To configure Ruby 1.9.2 as the version needed for your app, add the following to the top of your Gemfile:
ruby '1.9.2'
Working from a tutorial at http://mwmanning.com/2011/11/29/Run-Your-Jekyll-Site-On-Heroku.html. When I try to push to heroku I get a "build failed" message in the output.
Heroku logs shows
2013-01-30T05:29:54+00:00 heroku[slugc]: Slug compilation started
2013-01-30T05:31:36+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rack app
2013-01-30T05:31:38+00:00 heroku[web.1]: State changed from crashed to starting
2013-01-30T05:31:51+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -p 14276 -e $RACK_ENV`
2013-01-30T05:31:53+00:00 app[web.1]: bundler: command not found: thin
2013-01-30T05:31:53+00:00 app[web.1]: Install missing gem executables with `bundle install`
2013-01-30T05:31:54+00:00 heroku[web.1]: Process exited with status 1272013-01-30T05:31:54+00:00 heroku[web.1]: State changed from starting to crashed
Gemfile and Gemfile.lock both show that thin is installed.
source :rubygems
gem 'jekyll'
gem 'rdiscount'
gem 'rack-jekyll'
gem 'thin'
gem 'RedCloth'
Command bundle exec thin start works locally and bundle show thin shows that thin is installed specifically for the current gemset.
I can't understand why heroku still says that thin is missing?
For me a local bundle update fixed that problem.
Sorry, not a direct answer. But this method worked for me.
http://chriscontinanza.com/2011/06/15/Jekyll-to-heroku.html