I'm have a Rails 4 app on Heroku that I'm trying to deploy with two buildpacks. I'm not sure if I'm missing a step or if there is a bug, but when I push the code, the app deploys successfully. When I open it however, it crashes.
I've tried using the command heroku buildpacks:set https://github.com/bobbus/image-optim-buildpack.git and heroku buildpacks:set https://github.com/ddollar/heroku-buildpack-multi.git, but am only able to set one at a time, not both. It doesn't seem to matter which one I set, the app always crashes. Searching through the logs, I see the following:
heroku[web.1]: State changed from crashed to starting
heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
app[web.1]: bash: bundle: command not found
heroku[web.1]: Process exited with status 127
heroku[web.1]: State changed from starting to crashed
I'm no expert on bundler, but it seems like for some reason it's not recognizing the bundle command in my Procfile.
Here is my Procfile, which I should note has worked perfectly up until now.
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
I've also tried clearing out the buildpacks (heroku buildpacks:clear) and creating a .buildpacks file instead, but that yielded the same error.
Here is my .builcpacks file:
https://github.com/ddollar/heroku-buildpack-multi.git
https://github.com/bobbus/image-optim-buildpack.git
The documentation in the Heroku Dev Center and on the buildpacks themselves is pretty sparse as far as I can tell.
Using the .buildpacks multi manager isnt required because Heroku supports multiple buildpacks natively by passing --index when setting a buildpack for example:
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-ruby --index 1
heroku buildpacks:set https://github.com/shunjikonishi/heroku-buildpack-ffmpeg --index 2
Change something in your git repo && then do a -> git push heroku master
The Deploy will detect your buildpacks and will run them. To check what buildpacks are currently set in your app run: heroku buildpacks
If the two build packs you listed are the only two you're loading, I think you're missing the Ruby buildpack, which is where the "bundler" is defined:
https://github.com/heroku/heroku-buildpack-ruby
Note: If I were debugging this, I would ditch the buildpack-multi, and use just the Ruby buildpack to see if you can get that through the bundler error, then try to load another buildpack, and so on.
I see what you mean about the documentation. Pretty weak. Let me know if this helps.
Related
I am using gem Watir in my web application. When my user triggers an action the watir webdriver is opened and there's scrapping and posting on websites involved. I dont want my users to see the browser during the action so I am using watir with a ghostdriver using phantomJS as is explained here : http://watirmelon.com/2013/02/05/watir-webdriver-with-ghostdriver-on-osx-headless-browser-testing/
This works perfectly locally, however when I try using it on heroku deploy I get the following error:
Selenium::WebDriver::Error::WebDriverError (Unable to find phantomjs executable.):
Then I tried to add nodeJS & phantomJS buildpack as specified here
Is there a working nodejs/phantomjs Heroku buildpack?
I ran the following command line in the console :
➜ tennis-match git:(master) heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs.git --app we-tennis-staging
Buildpack set. Next release on we-tennis-staging will use https://github.com/heroku/heroku-buildpack-nodejs.git.
Run `git push heroku master` to create a new release using this buildpack.
➜ tennis-match git:(master) heroku buildpacks:add --index 1 https://github.com/stomita/heroku-buildpack-phantomjs.git --app we-tennis-staging
Buildpack added. Next release on we-tennis-staging will use:
1. https://github.com/stomita/heroku-buildpack-phantomjs.git
2. https://github.com/heroku/heroku-buildpack-nodejs.git
Run `git push heroku master` to create a new release using these buildpacks.
then pushed on my staging app
➜ tennis-match git:(master) git push staging master
Everything up-to-date
But I still get the error. Do you have any idea on how to fix this ?
This worked for me.
https://gist.github.com/edelpero/9257311
Note: After following the above instructions, make sure you have a Procfile with the code mentioned below:
web: bin/rails server -p $PORT -e $RAILS_ENV
I am trying to run a Rails app on Heroku using Unicorn.
I realized this morning that Heroku was starting Webrick instead of Unicorn.
I believe the problem was that the "Procfile" shows uppercase P on my iMac, but when I send to GIT it ends up lowercase. I fixed the case and sent it to Github. I view on Github and the case is correct.
Now my issue is I can't tell if Unicorn is running or not. How can I tell? What should I look for?
Thanks for the help!
PS -- Also, how can I tell for sure that the Git repository on Heroku has the Uppercase "Procfile"?
Type heroku ps -a <your_app_name> to see your running processes on Heroku. If you want to see the files you have on remote, either clone from Heroku remote or run heroku run bash -a <your_app_name> and then type ls.
While following the Rails 4 Beta version of Michael Hartl's Ruby on Rails Tutorial, my app fails to start on Heroku, but runs fine locally with bundle exec rails server. Checking heroku logs -t reveals the following error:
$ heroku[web.1]: State changed from crashed to starting
$ heroku[web.1]: Starting process with command `bin/rails server
-p 33847 -e $RAILS_ENV`
$ app[web.1]: bash: bin/rails: No such file or directory
$ heroku[web.1]: Process exited with status 127
$ heroku[web.1]: State changed from starting to crashed
$ heroku[web.1]: Error R99 (Platform error) -> Failed to launch the
dyno within 10 seconds
$ heroku[web.1]: Stopping process with SIGKILL
If I heroku run bash and check the bin directory, I can see that there is not a rails executable:
~$ ls bin
erb gem irb node rdoc ri ruby testrb
What have I done wrong? I followed the tutorial exactly.
I had this problem also since I upgraded to rails 4.0.0
Run this command
rake rails:update:bin
You can go here for more info
https://devcenter.heroku.com/articles/rails4
After struggling with this for a bit, I noticed that my Rails 4 project had a /bin directory, unlike some older Rails 3 projects I had cloned. /bin contains 3 files, bundle, rails, and rake, but these weren't making it to Heroku because I had bin in my global .gitignore file.
This is a pretty common ignore rule if you work with Git and other languages (Java, etc.), so to fix this:
Remove bin from ~/.gitignore
Run bundle install
Commit your
changes with git add . and git commit -m "Add bin back"
Push your changes to Heroku with git push heroku master
Steps :
bundle config --delete bin # Turn off Bundler's stub generator
rake rails:update:bin # Use the new Rails 4 executables
git add bin or git add bin -f # Add bin/ to source control
git commit -a -m "you commit message"
git push heroku master
heroku open
I had this issue because the permissions on my ~/bin directory were 644 instead of 755. Running rake rails:update:bin locally (on Mac/*nix) and then pushing the changes fixed the problem.
I had the very same problem that you did. The issue lied in the fact that the bin folder was never pushed to the heroku repository.
I looked, I looked, and then I looked again, there was no rule in the .gitignore file for the bin/ folder...
Then, after a lot of pain and anguish, I realized that a couple of months before I had created a global .gitignore that would ignore all bin folders of all my repositories (why lord, why??).
I deleted the global .gitignore, and everything worked fine.
We didn't have a myapp/bin directory in our rails 4 app, so we created one and then copied in the my app/script/rails file, plus the bundle and rake files from under rvm/ruby/bin and then added these to the repo for git and pushed it up to heroku and all was well.
On rails 5.2.6, rake app:update:bin worked for me. Now deployment to heroku is working.
I can confirm running rake rails:update:bin works, as said by #Ryan Taylor.
I think I had this problem because I originally created this Rails app on Windows. Running the command above on Linux solved for me.
Also, on changing from Windows to Linux for development, it is a good idea to delete Gemfile.lock file and run bundle install to generate it again without Windows specific gems listed there.
I have an issue with running the rails console at heroku (cedar-stack). Each of the following commands heroku run console, heroku run rails console, heroku run bundle exec rails console results in the following error-message:
Running bundle exec rails console attached to terminal... up, run.8155
Abort testing: Your Rails environment is running in production mode!
This error-message is a little bit confused. What kind of test tries heroku to start? I just want to fire up the console, which had worked fine 4 weeks ago.
For Cedar Stack and later:
heroku run rails console --app <app name>
Previous stacks could use this command:
heroku run console --app <app name>
If you have multiple environments (staging / production / etc) you need this command:
heroku run -a app-name console
If you only have a single environment and never setup staging or other environments you can just run:
heroku run console
https://github.com/nemrow/rails_app_cheatsheet/blob/master/heroku.rdoc
For some reason you need to explicitly define the console process in the Procfile:
# Procfile
web: script/rails server -p $PORT
console: script/rails console
This blog post has more details: http://platypus.belighted.com/blog/2013/01/21/ruby-2-rails-4-heroku/
I was with the same problem and I decided to do this and it worked
$ heroku run bash
$ cd bin
~/bin $ ruby rails console
You should just use heroku run console as others have answered.
Heroku only runs in one environment at a time, which is configured by the RAILS_ENV and RACK_ENV environments variables.
When you connect, the console will use the correct environment automatically.
It's my first attempt to get Redis working on Heroku.
I've added one worker dyno (just today, so didn't pay yet), added RedisToGo Nano add-on, tested background jobs on my local machine, and pushed the app to heroku.
heroku ps
gives
=== web: `bundle exec rails server -p $PORT`
web.1: up 2013/03/03 18:26:09 (~ 37m ago)
=== worker: `bundle exec rake jobs:work`
worker.1: crashed 2013/03/03 19:02:15 (~ 1m ago)
Sidekiq Web Interface says that one job is enqueued, but zero processed or failed.
I'm guessing it's because my worker dyno is crashed.
Are there any noob mistakes that I don't know about?
(e.g. I need to run some command to start listening to background jobs etc)
heroku logs --tail doesn't show any errors, so I don't understand why my worker dyno chashes.
I did some research and fixed it like this:
Under app's root directory I created a file called "Procfile" with this content:
web: bundle exec rails server -p $PORT
worker: bundle exec sidekiq -c 5 -v
Got this idea from here.
After that it worked ok.
Also make sure you setup REDIS_PROVIDER:
heroku config:set REDIS_PROVIDER=REDISTOGO_URL
Sidekiq's GitHub page also has instruction. Click here