I am new to ruby, git and heroku. I was trying to build a simple Hello World app and deploy it on heroku. I see the following error in the logs when I try to access the site using the heroku provided URL. Could you tell me what I am not doing right.
2011-07-03T01:15:06+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2011-07-03T01:15:06+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2011-07-03T01:15:06+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new'
2011-07-03T01:15:06+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `<main>'
2011-07-03T01:15:06+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
2011-07-03T01:15:06+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
2011-07-03T01:15:06+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
2011-07-03T01:15:06+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
2011-07-03T01:15:06+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
2011-07-03T01:15:06+00:00 heroku[web.1]: Process exited
2011-07-03T01:15:07+00:00 heroku[web.1]: State changed from starting to crashed
config.ru file
require 'myapp2'
run Sinatra::Application
myapp2.rb
require 'rubygems'
require 'sinatra'
get '/' do
'Hello World'
end
You're missing the top of the stack trace, but it looks like the problem is the require.
In config.ru change
require 'myapp2'
to
require './myapp2'
or
require File.expand_path("../myapp2", __FILE__)
Ruby 1.9.2 no longer has the current directory in the load path, so require 'myapp2' isn't able to find your app file which is in the same directory.
If this is working on your local machine, but not on Heroku, then you're likely using a different version of Ruby, probably 1.8.7. It would be a good idea to install 1.9.2 locally so that you're using the same version in development and production. Alternatively you could change the Heroku stack you're using; have a look at the Heroku stack docs
Related
I developed my first app with Napa and now I'm trying to deploy it on my production server.
I probably did something wrong because napa server (or bundle exec napa server) throws an error and I have no idea to what to look for to solve it...
Here my stack trace
releases/current]# napa server
Napa server starting...
/home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/gems/napa-0.5.0/lib/napa/cli/base/server.rb:14:in spawn: can't get Master/Slave device (RuntimeError)
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/gems/napa-0.5.0/lib/napa/cli/base/server.rb:14:in `server'
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/gems/napa-0.5.0/bin/napa:5:in `<top (required)>'
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/bin/napa:23:in `load'
from /home/partners/.rvm/gems/ruby-2.2.3#my_awesome_app/bin/napa:23:in main
Indeed, this works! bundle exec rackup config.ru
Why? It seems I have some issues with PTY. Maybe is a matter of permissions?
Trying to learn Sinatra I just deployed a simple app to heroku.
My config file:
require './main'
require 'sinatra'
run Sinatra::Application
Gemfile:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'sinatra'
gem 'slim'
gem 'sass'
gem 'dm-core'
gem 'dm-migrations'
gem 'thin'
gem 'pg', :group => :production
gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development
I get following error in the logs:
2015-03-31T09:13:54.051645+00:00 heroku[web.1]: State changed from crashed to starting
2015-03-31T09:13:57.281158+00:00 heroku[web.1]: Starting process with command `bundle exec ruby main.rb -p 28463`
2015-03-31T09:13:59.598142+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:163:in `require': cannot load such file -- dm-sqlite-adapter (LoadError)
2015-03-31T09:13:59.598161+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:163:in `load_adapter'
2015-03-31T09:13:59.598164+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:133:in `adapter_class'
2015-03-31T09:13:59.598165+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:13:in `new'
2015-03-31T09:13:59.598167+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core.rb:230:in `setup'
2015-03-31T09:13:59.598169+00:00 app[web.1]: from /app/song.rb:5:in `block in <top (required)>'
2015-03-31T09:13:59.598171+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1410:in `configure'
2015-03-31T09:13:59.598172+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1989:in `block (2 levels) in delegate'
2015-03-31T09:13:59.598174+00:00 app[web.1]: from /app/song.rb:4:in `<top (required)>'
2015-03-31T09:13:59.598178+00:00 app[web.1]: from main.rb:6:in `require'
2015-03-31T09:13:59.598187+00:00 app[web.1]: from main.rb:6:in `<main>'
2015-03-31T09:14:00.479331+00:00 heroku[web.1]: State changed from starting to crashed
2015-03-31T09:14:00.461548+00:00 heroku[web.1]: Process exited with status 1
I tried the solution proposed here but it did not work.
Thanks in advance for ideas
I think you need datamapper in your Gemfile.
gem "datamapper"
I'm trying to deploy my Ruby on Rails app to Heroku with Unicorn. I followed the tutorial on Heroku website. But it shows:
Precompiling assets failed.
Here is the running result:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
rake aborted!
uninitialized constant Rack::Timeout
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/config/initializers/timeout.rb:1:in `<top (required)>'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/engine.rb:649:in `block in load_config_initializer'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.0.rc1/lib/active_support/notifications.rb:161:in `instrument'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/engine.rb:648:in `load_config_initializer'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/engine.rb:613:in `block (2 levels) in <class:Engine>'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/engine.rb:612:in `each'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/engine.rb:612:in `block in <class:Engine>'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/initializable.rb:30:in `run'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/initializable.rb:44:in `each'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/initializable.rb:44:in `tsort_each_child'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/application.rb:286:in `initialize!'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/config/environment.rb:5:in `<top (required)>'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/application.rb:262:in `require_environment!'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/railties-4.1.0.rc1/lib/rails/application.rb:346:in `block in run_tasks_blocks'
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed.
Push rejected, failed to compile Ruby app
I use Ruby2.0, Ruby on Rails 4.1.0.rc1.
It looks like your problem is actually related to Rack::Timeout and not asset compilation.
uninitialized constant Rack::Timeout
/tmp/build_d3989303-c1d8-4020-9b98-eb9e1834f0d0/config/initializers/timeout.rb:1:in `<top (required)>'
Have you included the rack-timeout gem in your gemfile? And ran bundle install after that?
gem "rack-timeout"
Remove the timeout setting:
rm config/initializers/timeout.rb
Heroku times-out all requests at 30 seconds but the process will continue running in the background.
If you want to avoid that, re-add the line above but put rack-timeout in your Gemfile.
I would suggest trying the following:
heroku labs:enable user-env-compile
If this fails, you could always precompile your production assets, add them to your codebase and push them to heroku yourself.
RAILS_ENV=production rake assets:precompile
git add .
git commit -m 'serving up my precompiled assets'
git push origin master
git push origin heroku
I am trying to get up and running with Sinatra and Mustache in OSX Lion. After a lot of googling around I am no further in fixing the issue. I am pretty sure it has to do with Ruby permissions in OSX because the error (below) starts with the first line of the example config.ru file (require 'app'). The project is here ( https://github.com/defunkt/mustache-sinatra-example)
here is my error
Boot Error
Something went wrong while loading config.ru
LoadError: no such file to load -- app
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
config.ru:1:in `block in inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:51:in `instance_eval'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `eval'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in `assemble_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in `call!'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:134:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/handler/webrick.rb:59:in `service'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
any help would be much appreciated. Thanks in advance
In ruby 1.9.2 current dir isn't searched for required files, so you should specify path
require './app'
Similarly, in app.rb you will need to change
6 require 'views/layout' to require './views/layout'
and
9 :views => 'views', to :views => './views',
Change the line
require 'app'
to
require './app'
It looks like you're using Ruby 1.9.2. The current directory was removed from Ruby's load path in this version, so require 'app' no longer works, you need to specify that the file is in the current directory with require './app'. I assume that example project was built using an earlier version of Ruby.
I've been trying to get a simple hello world web app running on Sinatra.
I have the following setup:
config.ru
require 'hello.rb'
run Sinatra::Application
hello.rb
require "sinatra"
get "/" do
"Hello World!\n"
end
Gemfile
source :rubygems
gem 'sinatra'
This works on my local machine if I run ruby hello.rb, ruby1.9.1 hello.rb or rackup and go to the correct address in my browser. However, this doesn't work when deployed to heroku or if I run rackup1.9.1. I get the following error:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- hello.rb (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from config.ru:1:in `block in <main>'
from /usr/lib/ruby/1.9.1/rack/builder.rb:46:in `instance_eval'
from /usr/lib/ruby/1.9.1/rack/builder.rb:46:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /usr/lib/ruby/1.9.1/rack/builder.rb:35:in `eval'
from /usr/lib/ruby/1.9.1/rack/builder.rb:35:in `parse_file'
from /usr/lib/ruby/1.9.1/rack/server.rb:113:in `app'
from /usr/lib/ruby/1.9.1/rack/server.rb:189:in `wrapped_app'
from /usr/lib/ruby/1.9.1/rack/server.rb:155:in `start'
from /usr/lib/ruby/1.9.1/rack/server.rb:83:in `start'
from /usr/bin/rackup1.9.1:4:in `<main>'
How can I get this working? I'm guessing config.ru should be different but I don't know what to change.
Try doing
require './hello'
or
require_relative 'hello'
The current directory is not present in the LOAD_PATH by default in Ruby 1.9.2.