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 have a working Rails app on my local Windows XP machine. I want to upload it on Heroku. I follow this tutorial https://devcenter.heroku.com/articles/rails3.
When I ran git push heroku master, it failed:
-----> Ruby/Rails app detected
-----> WARNING: Removing `Gemfile.lock` because it was generated on Windows.
Bundler will do a full resolve so native gems are handled properly.
This may result in unexpected gem versions being used in your app.
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Received disconnect from 50.19.85.132: 10: user closed connection
fatal: The remote end hung up unexpectedly
What do I have to do now?
I saw the log, there are some issues like these ones:
2013-04-28T21:18:03.384881+00:00 app[web.1]: /app/app/assets/images/cards/resize.rb:23:in `open': No such file or directory -
C:\sbox\ruby\cards2 (Errno::ENOENT)
2013-04-28T21:18:03.385662+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in
`wrapped_app'
2013-04-28T21:18:04.689716+00:00 heroku[web.1]: State changed from starting to crashed
2013-04-28T21:18:05.596424+00:00 heroku[web.1]: Process exited with status 1
2013-04-28T21:28:27.556270+00:00 heroku[web.1]: State changed from crashed to starting
2013-04-28T21:28:29.459229+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 3598`
2013-04-28T21:18:03.385424+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/con
figurable.rb:30:in `method_missing'
2013-04-28T21:28:34.613321+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/con
figurable.rb:30:in `method_missing'
I removed resize.rb:23 file. It is for re-sizing images, app doesn't use, I just left it there on development and forgot to delete when uploaded my app on Heroku. On my local machine it is not run by itself, but Heroku for some reason started it. There was a function call to C:\sbox\ruby\cards2 location and that's why the error happened, I thought. Ok, I removed the file. Do not know, though, about other issues.
But what do I need to do now? How to start the process again? I ran git push heroku master again but got:
C:\sbox\ruby\Sites\Heroku\Cards>git push heroku master
Everything up-to-date
Nothing works but Heroku says that everything is up-to-date.
Is there a way to see all my app files on Heroku server the way you can see your files on shared hosting?
Try adding a commit with some small change, like a Readme change or something. It should force heroku to re-deploy your app.
I'm deploying a Rails 3.2.11 app on Heroku with Thin as my server. When I push to Heroku, it boots Thin just fine, but then it seems to also try to boot WEBrick.
My Procfile is as follows:
web: bundle exec rails server -p $PORT thin -e $RACK_ENV
And my Heroku logs:
2013-04-11T14:52:28.276634+00:00 heroku[api]: Release v21 created by XXXXXX#gmail.com
2013-04-11T14:52:28.331285+00:00 heroku[api]: Deploy 6f63ed4 by XXXXXX#gmail.com
2013-04-11T14:52:28.432372+00:00 heroku[web.1]: State changed from crashed to starting
2013-04-11T14:52:28.965697+00:00 heroku[slugc]: Slug compilation finished
2013-04-11T14:52:30.218480+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 9009 thin -e $RACK_ENV`
2013-04-11T14:52:32.898285+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-04-11T14:52:32.897830+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-04-11T14:52:34.350938+00:00 app[web.1]: [2013-04-11 14:52:34] INFO WEBrick::HTTPServer#start: pid=2 port=2010
2013-04-11T14:52:34.350132+00:00 app[web.1]: [2013-04-11 14:52:34] INFO WEBrick 1.3.1
2013-04-11T14:52:34.350707+00:00 app[web.1]: [2013-04-11 14:52:34] WARN TCPServer Error: Address already in use - bind(2)
2013-04-11T14:52:34.350132+00:00 app[web.1]: [2013-04-11 14:52:34] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-04-11T14:52:34.407830+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-04-11T14:52:34.407675+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 2010, should be 9009 (see environment variable PORT)
2013-04-11T14:52:35.572955+00:00 heroku[web.1]: State changed from starting to crashed
2013-04-11T14:52:35.560772+00:00 heroku[web.1]: Process exited with status 137
Why is it doing this? What am I missing?
Try using Thin instead of WEBrick. You can do this by simply adding this to your gemfile:
gem 'thin'
Then run bundle install, commit the new Gemfile and Gemfile.lock, then push to Heroku.
WEBrick is not meant for production use.
It turns out that a plugin I was using, SyntaxHighlighter, had some files in its test directory that started WEBrick. I just removed those, committed, pushed, and it worked fine.
I'm pretty new to Rails here and I've followed Ruby on Rails Tutorial for most of it. I have since decided to make my own application, but using the Rails 4 gem in beta. I have installed PostgreSQL on my local machine (Windows 7) and done development. Everything works great! (I love Rails much more than C#, ASP, .NET work that I do for a living!)
However, once I decided to push to Heroku, I've been pulling my hair out. Prior to pushing to Heroku, I did the standard:
c:\Sites\elms>git add .
c:\Sites\elms>git commit -m "My comment"
c:\Sites\elms>git push
c:\Sites\elms>git push heroku master
I've downloaded and installed the Heroku Toolbelt (not heroku gem.) The first error told me I needed to make sure that my Gemfile specified Ruby >= 1.9.3, so I added "ruby 1.9.3" to the top of my Gemfile:
source 'https://rubygems.org'
ruby "1.9.3"
gem 'rails', '4.0.0.beta1'
gem 'pg'
gem 'haml-rails'
gem 'httparty'
gem 'devise', git: 'git://github.com/plataformatec/devise.git', branch: 'rails4'
gem 'cancan'
gem 'bootstrap-sass'
gem 'formtastic'
gem 'formtastic-plus-bootstrap'
group :development do
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
gem 'guard-spork'
gem 'guard-rspec'
gem 'meta_request'
gem 'rb-notifu'
gem 'schema_to_scaffold'
gem 'wdm', :platforms => [:mswin, :mingw], :require => false
gem 'win32console'
end
group :development, :test do
gem 'rspec-rails'
gem 'pry'
gem 'spork-rails', git: 'git://github.com/sahilm/spork-rails.git', branch: 'rails-4'
gem 'spork', '~> 1.0.0rc3'
end
group :test do
gem 'capybara'
gem 'factory_girl_rails'
gem "shoulda-matchers"
end
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.0.1'
The push finally worked without any issues, but when I tried to migrate the database, I got the following:
c:\Sites\elms>heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.2205
/usr/bin/env: ruby.exe: No such file or directory
I have also tried: heroku run bin/rake db:migrate, and it gives same error. I am using Getting Started with Rails 4.x on Heroku to push my Rails 4 app to Heroku. Any help would be greatly appreciated!
Oh, I also had an issue after running:
c:\Sites\elmx>gem install rails --pre
I solved this by adding C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\bin; to my environment Path variable in Windows 7 (it was giving me an error that it couldn't find rails when trying to execute anything such as:
rails -v
rails g controller User
But if I typed just:
rails
It would give me all of the commands I could use (as if running rails -h)
I set up my machine by using the Windows Rails Installer, then installing the Rails 4 gem. This is extremely frustrating and I've scoured the internet trying to find someone with the same problem.
EDIT 1:
I just deleted my user Path environment variable and modified my system Path environment variable to look like such:
C:\RailsInstaller\Ruby1.9.3\bin;C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\bin;C:\Program Files (x86)\git\cmd;C:\Program Files (x86)\Heroku\bin
Updated my path variable to the above and uninstalled Heroku Toolbelt, then re-installed it (hence why the Heroku piece is in the path variable) and tried the following:
c:\Sites\elms>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
c:\Sites\elms>rails -v
Rails 4.0.0.beta1
c:\Sites\elms>heroku -v
! `-v` is not a heroku command.
! Perhaps you meant `-h`.
! See `heroku help` for a list of available commands.
c:\Sites\elms>heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.2100
/usr/bin/env: ruby.exe: No such file or directory
c:\Sites\elms>heroku run bin/rake db:migrate
Running `bin/rake db:migrate` attached to terminal... up, run.2872
/usr/bin/env: ruby.exe: No such file or directory
EDIT 2:
So I got a little further in this venture. I found out that I could execute:
c:\Sites\elms>heroku run bash
~ $ cd bin
~/bin $ ruby rake db:migrate
And that would then run rake and migrate my database on Heroku. But the problem gets worse! I try to navigate to the page and it tells me that there is something wrong, so I run the log file and this is what I get:
c:\Sites\elms>heroku logs
2013-03-16T05:34:20+00:00 heroku[api]: Enable Logplex by
2013-03-16T05:34:20+00:00 heroku[api]: Release v2 created by
2013-03-16T05:34:36+00:00 heroku[slugc]: Slug compilation started
2013-03-16T05:35:37+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 13423 -e $RAILS_ENV`
2013-03-16T05:35:37+00:00 heroku[slugc]: Slug compilation finished
2013-03-16T05:35:37+00:00 app[web.1]: bash: bin/rails: No such file or directory
2013-03-16T05:35:39+00:00 heroku[web.1]: Process exited with status 127
2013-03-16T05:35:39+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 33539 -e $RAILS_ENV`
2013-03-16T05:35:40+00:00 app[web.1]: /usr/bin/env: ruby.exe: No such file or directory
2013-03-16T05:35:41+00:00 heroku[web.1]: Process exited with status 127
2013-03-16T05:35:41+00:00 heroku[web.1]: State changed from starting to crashed
2013-03-16T05:35:41+00:00 heroku[web.1]: State changed from crashed to starting
2013-03-16T05:35:44+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 23452 -e $RAILS_ENV`
2013-03-16T05:35:44+00:00 app[web.1]: /usr/bin/env: ruby.exe: No such file or directory
This is getting really frustrating. I have no clue what the heck /usr/bin/env is. The only thing I can guess is that it's like PATH for Windows. If this is the case, why does the server not know where ruby.exe is?
I did make a non Rails 4 application and was able to post it to Heroku and view it with no issues. This is really getting on my nerves.
You need to change in your application first line of the 3 files:
bin/bundle
bin/rails
bin/rake
Instead
#!/usr/bin/env ruby.exe
must be
#!/usr/bin/env ruby
That's why is error:
/usr/bin/env: ruby.exe: No such file or directory
Then you do successfully:
heroku run rake db:migrate
It's work for me.
I had a similar issue and as others have already stated, changing the below helped.
#!/usr/bin/env ruby.exe to #!/usr/bin/env ruby
However, I also needed to remove some hidden carriage returns which were still present from developing on Windows originally (I guess?).
I used dos2unix to do this.
dos2unix bin/bundle bin/rake bin/rails
After that, I committed my changes, pushed to heroku and all was good.
I had this same problem, changed ruby.exe to ruby in the three files as described above, executed the
git push heroku master
step, which told me everything was up to date. Trying the
heroku run rake db:migrate
step again, it still didn't work; I got the same error about no such file or directory for ruby.exe. I examined my gemfile.lock as directed, but didn't see anything that looked windows-y.
I then executed these:
git add .
git commit -m "My comment"
and tried again with
git push heroku master
This time, boatloads of messages went by, including:
Removing Gemfile.lock because it was generated on Windows.
so perhaps there was something wrong with it and I just didn't know what I should be looking for in it.
Trying again to
heroku run rake db:migrate
looks to have worked, as I got
Running rake db:migrate attached to terminal... up, run.3260
== CreateUsers: migrating ====================================================
-- create_table(:users)
-> 0.0409s
== CreateUsers: migrated (0.0412s) ===========================================
My best guess is that the change to remove the .exe from bundle, rake, and rails did not actually get pushed up on the first try of
git push heroku master
and the
git add .
and
git commit -m "My comment"
were necessary to make it get pushed up. This is my first attempt at anything with git/heroku/ruby, so I don't know enough to say why the other two commands were required, but leave my experience documented here in case it helps anybody else.
Thanks so much for the clue above that it was the .exe in those three files that caused the problem.
bin/bundle
bin/rails
bin/rake
Instead
#!/usr/bin/env ruby.exe
must be
#!/usr/bin/env ruby
(thanks to previous post)
make sure there are no references to windows in the gemfile.lock - they can just be deleted
then
git push heroku master
if there are still problems use
heroku logs (copying text to a text editor makes it easier to cut and paste for solutions)
Try this:
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
and then install Nokogiri:
gem install nokogiri
My heroku deployment is crashing with following errors.
2012-12-12T17:16:18+00:00 app[web.1]: bash: bundle: command not found
2012-12-12T17:16:19+00:00 heroku[web.1]: Process exited with status 127
2012-12-12T17:16:19+00:00 heroku[web.1]: State changed from starting to crashed
The Heroku documentation for this error is to set PATH and GEM variables as described in https://devcenter.heroku.com/articles/changing-ruby-version-breaks-path I tried that, however that too is not helping.
→ heroku config:add PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
→ heroku config:add GEM_PATH=vendor/bundle/ruby/1.9.1
→ heroku run rake db:migrate
Running rake db:migrate attached to terminal... up, run.7130
bash: bundle: command not found
Next, I tried setting Ruby version in my Heroku app. This increased the slugsize. But app was still not up.
Gemfile
ruby "1.9.2"
Pushed to Heroku
-----> Using Ruby version: ruby-1.9.2
-----> Installing dependencies using Bundler version 1.2.2
heroku run "ruby -v"
Running `ruby -v` attached to terminal... up, run.4483
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-linux]
Can someone please advice
The error is because your path is incorrect.
If you're trying to use Ruby 1.9.3 you don't need to do anything,
it's the default Ruby so you can remove those config vars.
If you're using
1.8.7 or 1.9.2, then upgrade to 1.9.3 as it's current.
If you're looking at using Ruby 2.0.0.p3 - you're on your own ;)