Pivotal Knowledge Base

Follow

Troubleshooting error "None of the buildpacks detected a compatible application, exit status 222"

Environment 

Product Version
Pivotal Cloud Foundry® (Pivotal CF)   
Tile Elastic Runtime all versions
Component Buildpack

Overview

In this article, we will provide guidance for troubleshooting and to perform a root cause analysis (RCA) of "None of the buildpacks detected a compatible application" errors.

Symptom

When pushing app to Pivotal CF or Pivotal Web Services(PWS) without specifying buildpack, it fails with error: 

Starting app myapp in org my org / space myspace as username... 

Downloading binary_buildpack... 
Downloading staticfile_buildpack... 
Downloading java_buildpack... 
Downloading nodejs_buildpack... 
Downloading go_buildpack... 
Downloaded go_buildpack 
Downloading python_buildpack... 
Downloaded nodejs_buildpack 
Downloading php_buildpack... 
Downloaded java_buildpack 
Downloading liberty_buildpack... 
Downloaded binary_buildpack 
Downloading ruby_buildpack... 
Downloaded ruby_buildpack 
Downloaded php_buildpack 
Downloaded liberty_buildpack 
Downloaded python_buildpack 
Downloaded staticfile_buildpack 
Creating container 
Successfully created container 
Downloading app package... 
Downloaded app package (3.7K) 
Staging... 
None of the buildpacks detected a compatible application 
Exit status 222 
Staging failed: Exited with status 222 
Destroying container 
Successfully destroyed container

FAILED 
Error restarting application: NoAppDetectedError

TIP: Buildpacks are detected when the "cf push" is executed from within the directory that contains the app source code.
Use 'cf buildpacks' to see a list of supported buildpacks.
Use 'cf logs nitindemo --recent' for more in depth log information. 

Cause 

When pushing an app, Cloud Foundry determines which buildpack to use by running each enabled buildpacks’ detect script(bin/detect) during staging.

Each buildpack has a position in a priority list (identified by running cf buildpacks). Cloud Foundry checks if the buildpack in position 1 is a compatible buildpack. If the position 1 buildpack is not compatible, Cloud Foundry moves on to the next buildpack. Cloud Foundry continues this process until the correct buildpack is found. This script takes app's root directory(in case of Java app, it's jar or war file) as a single argument and must return an exit code of 0 if the app present at the directory can be serviced by this buildpack. 

(Ruby buidpack bin/detect script example)

#!/bin/bash

if [ -f "$1/Gemfile" ]; then
  SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  echo "ruby $(cat $SCRIPT_DIR/../VERSION)"
  exit 0
else
  echo "no"
  exit 1
fi

If no buildpack is compatible cf push fails with the error:

None of the buildpacks detected a compatible application 
Exit status 222 
Staging failed: Exited with status 222 
Destroying container 
Successfully destroyed container

FAILED 
Error restarting application: NoAppDetectedError

Resolution

Follow the steps to resolve this issue:

  1. Check if the app is compatible with a buildpack. As an example for Ruby app, Gemfile must be placed under app's root directory.
  2. Check if app path is correctly specified by cf push -p option or path entry in deployment manifest. For Java app, it must be pointed to a valid jar or war file, if using an executable jar, a main-class needs to be specified in config/java_main.yml. For Non-Java app, it must be pointed to app root directory. 
  3. For running arbitrary binary web servers, please specify binary_buildpack with cf push -b option or buildpack entry in deployment manifest.

Additional Information 

If the buildpack is not specified in cf push, this would require downloading all system buildpacks and will try to execute detect script until the script is able to find a compatible buildpack which may take a long time and would cause app staging timeout. It's recommended to specify the buidpack with cf push -b option(or buildpack entry in manifest) to skip the buildpack detection.

There are apps written with Java Spring, Ruby, PHP, NodeJS, etc available at Github - Cloud Foundry Sample Applications, please refer the sample apps if get any development/deployment issues.

As detection criteria varies with different buildpacks, it's recommended to look into detect scripts(/bin/detect) for further details. Here is the github repository for buildpacks which are pre-installed with Pivotal CF.

 

Comments

Powered by Zendesk