[RAILS] What to do if deployment fails on Heroku (Ruby app not detected)

I'm running a self-made app on Heroku, but I encountered a phenomenon that caused an error when building.

This is a Heroku-specific error, and there wasn't much information on the internet, so here's a solution.

View Build Log

View the Build Log from Activity on the console. Comparing the log at the time of failure and the log at the time of normal, when it fails, it is said that Ruby application-specific Build-related processing such as Ruby app detected and ʻInstalling bundler 2.0.2` is not performed. understood.

** In case of failure **

-----> nginx-buildpack app detected
./
./nginx
./mime.types
./nginx-debug
-----> nginx-buildpack: Installed nginx/1.18.0 to app/bin
-----> nginx-buildpack: Added start-nginx to app/bin
-----> nginx-buildpack: Added start-nginx-debug to app/bin
-----> nginx-buildpack: Added start-nginx-solo to app/bin
-----> nginx-buildpack: Default mime.types copied to app/config/
-----> nginx-buildpack: Default config copied to app/config.
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 4.9M
-----> Launching...
       Released v154
       https://supplebox.herokuapp.com/ deployed to Heroku
...Abbreviation

Normal

-----> Ruby app detected
-----> Installing bundler 2.0.2
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.7.1
-----> Installing dependencies using bundler 2.0.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       [DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag
       [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path 'vendor/bundle'`, and stop using this flag
       [DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'development:test'`, and stop using this flag
       [DEPRECATED] The --binstubs option will be removed in favor of `bundle binstubs`
       Fetching gem metadata from https://rubygems.org/............
       Using rake 13.0.1
...Abbreviation

It doesn't seem to be recognized as a Ruby app

It seems that the cause is not Ruby app detected. I knew that Heroku would automatically build for Ruby if it was a Rails application, but I investigated the processing around here.

--About Heroku's Ruby support https://devcenter.heroku.com/articles/ruby-support#rails-6-x-applications

--About Heroku buildpacks https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack

Apparently, Heroku automatically detects that it is a Ruby application from the source code and automatically builds the application using a series of build processes (build packs).

This event is caused by the Ruby build pack not being started, so I will try adding the build pack manually.

Build pack added

https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack

Check the current build pack and add it by referring to.

Originally there was a build pack called heroku-community / nginx, but I installed the build packs heroku / nodejs and heroku / ruby in order using the ʻindex` option.

$ heroku buildpacks
=== supplebox Buildpack URL
heroku-community/nginx

$ heroku buildpacks:add --index 1 heroku/nodejs
Buildpack added. Next release on supplebox will use:
  1. heroku/nodejs
  2. heroku-community/nginx
Run git push heroku main to create a new release using these buildpacks.

$ heroku buildpacks:add --index 2 heroku/ruby
Buildpack added. Next release on supplebox will use:
  1. heroku/nodejs
  2. heroku/ruby
  3. heroku-community/nginx
Run git push heroku main to create a new release using these buildpacks.

Rebuild. Healed !!

Heroku doesn't seem to be able to rebuild, so merge and redeploy the PR with an empty commit.

And healed.

The Build Log shows Ruby app detected, and the Ruby-related build works fine and deploys successfully.

Congratulations.

Recommended Posts

What to do if deployment fails on Heroku (Ruby app not detected)
What to do if audio is not available on discordrb
What to do if changes are not reflected after automatic deployment to EC2
What to do if the background image is not applied after deployment
What to do if mvn archetype: generate fails
[Swift] What to do if the app icon is set but not reflected
What to do if Docker Desktop fails to launch on your M1 MacBook Pro
What to do if the debug gem installation fails
What to do if TextToSpeech doesn't work on Android 11
What to do if password authentication fails in Docker/Postgres
What to do if FacesMessage is set but not displayed
What to do if you installed Ruby with rbenv but the version does not change
[Ubuntu 20.04] What to do if the external monitor is not recognized
[Rails] What to do if data is not registered in DB
[Logback] What to do if unnecessary files do not disappear during rotation
Notes on what to do if Ubuntu 20.04 installation on Virtual box 6.1 (Windows10) fails with "Error 5 Input / output error"
What to do if the app is not created with the latest Rails version installed when rails new
How to redo a deployment on Heroku
Deploy to Heroku [Ruby on Rails] Beginner
What to do if you install Ubuntu
What to do if the prefix c is not bound in JSP
What to do when Blocked Host: "host name" appears in Ruby on Rails
no space left on device What to do if an error occurs
What to do if you get an error when you hit Heroku logs
What to do if you get a MiniMagick vulnerability alert on GitHub
What to do if you get Could not locate Gemfile or .bundle / directory
What to do if the changes are not reflected in the jar manifest file
What to do if the server tomcat dies
Ssh login to the app server on heroku
What to do if you push incorrect information
What to do if you have installed Java for OS X on macOS
What to do if build from command line fails in Android development environment
What to do if SPA URL loading cannot be detected by WebView shouldOverrideUrlLoading
What to do when debugging "Source not found"
What to do if the rails server doesn't run out on AWS cloud9
What to do if ffi installation fails when launching an application in Rails
What to do if the update does not take effect after deploying Rails AWS
[Ruby on Rails] If there are duplicate records when registering data, do not register
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What to do if you can't find your API key after deploying to Rails heroku
What to do if the JSONHint annotation does not work with lombok and JSONIC
What to do if you get a port error when docker-compose up on Mac
What to do if the breakpoint is shaded and does not stop during debugging
What to do if the Rails server can't start
What to do when JSF tags do not become HTML
What to do if ClassNotFoundException occurs when starting Tomcat
What to do if rails server can't be stopped
What to do if you accidentally create a model
[Ruby On Rails] How to reset DB in Heroku
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
What to do when Rails on Docker does not reflect controller changes in the browser
What to do if you get a java.io.IOException in GlassFish
Ruby on Rails record search, create if not find_or_create_by method
# What to do if you accidentally do rails db: migrate: drop
What to do if the adb command cannot be executed
What to do if mysql2 gets a bundle install error
What to do if you can't use the rails command
What to do if you go offline due to SSL certificate error when running Jenkins on Mac
[Spring Boot] What to do if an HttpMediaTypeNotAcceptableException occurs on an endpoint for which produces is set
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
What to do if you get "Changes not staged for commit:" when you git status after git add.