Repository: railwayapp/nixpacks
Pull request #656 (2022-11-04 18:12:53)

Better output if there are no phases in the build plan
This PR shows a better error message if there are no phases in the generated build plan


![image](https://user-images.githubusercontent.com/3044853/200046491-75bccafb-45c7-4c7d-9681-632bb6728ce4.png)



Patch:
diff --git a/src/nixpacks/builder/docker/docker_image_builder.rs b/src/nixpacks/builder/docker/docker_image_builder.rs
index 9c5b914..e41434f 100644
--- a/src/nixpacks/builder/docker/docker_image_builder.rs
+++ b/src/nixpacks/builder/docker/docker_image_builder.rs
@@ -65,11 +65,17 @@ impl ImageBuilder for DockerImageBuilder {
             return Ok(());
         }
 
-        println!("{}", plan.get_build_string()?);
+        let phase_count = plan.phases.clone().map_or(0, |phases| phases.len());
+        if phase_count > 0 {
+            println!("{}", plan.get_build_string()?);
 
-        let start = plan.start_phase.clone().unwrap_or_default();
-        if start.cmd.is_none() && !self.options.no_error_without_start {
-            bail!("No start command could be found")
+            let start = plan.start_phase.clone().unwrap_or_default();
+            if start.cmd.is_none() && !self.options.no_error_without_start {
+                bail!("No start command could be found")
+            }
+        } else {
+            println!("\nNixpacks was unable to generate a build plan for this app.\nPlease check the documentation for supported languages: https://nixpacks.com");
+            std::process::exit(1);
         }
 
         self.write_app(app_src, &output).context("Writing app")?;
diff --git a/src/providers/haskell.rs b/src/providers/haskell.rs
index e986692..a5ba893 100644
--- a/src/providers/haskell.rs
+++ b/src/providers/haskell.rs
@@ -20,7 +20,7 @@ pub struct HaskellStackProvider {}
 
 impl Provider for HaskellStackProvider {
     fn name(&self) -> &str {
-        "haskell_stack"
+        "haskell"
     }
 
     fn detect(&self, app: &App, _env: &Environment) -> Result<bool> {
diff --git a/src/providers/java.rs b/src/providers/java.rs
index 1ee6d0b..8d78c10 100644
--- a/src/providers/java.rs
+++ b/src/providers/java.rs
@@ -15,7 +15,7 @@ pub struct JavaProvider {}
 
 impl Provider for JavaProvider {
     fn name(&self) -> &str {
-        "Java"
+        "java"
     }
 
     fn detect(&self, app: &App, _env: &Environment) -> Result<bool> {
diff --git a/src/providers/ruby.rs b/src/providers/ruby.rs
index 04a6d4e..18c63b2 100644
--- a/src/providers/ruby.rs
+++ b/src/providers/ruby.rs
@@ -17,7 +17,7 @@ const BUNDLE_CACHE_DIR: &str = "/root/.bundle/cache";
 
 impl Provider for RubyProvider {
     fn name(&self) -> &str {
-        "Ruby"
+        "ruby"
     }
 
     fn detect(&self, app: &App, _env: &Environment) -> Result<bool> {


Test patch:
diff --git a/tests/snapshots/generate_plan_tests__java_gradle_hello_world.snap b/tests/snapshots/generate_plan_tests__java_gradle_hello_world.snap
index 0cafdd7..7857656 100644
--- a/tests/snapshots/generate_plan_tests__java_gradle_hello_world.snap
+++ b/tests/snapshots/generate_plan_tests__java_gradle_hello_world.snap
@@ -6,7 +6,7 @@ expression: plan
   "providers": [],
   "buildImage": "[build_image]",
   "variables": {
-    "NIXPACKS_METADATA": "Java"
+    "NIXPACKS_METADATA": "java"
   },
   "phases": {
     "build": {
diff --git a/tests/snapshots/generate_plan_tests__java_maven.snap b/tests/snapshots/generate_plan_tests__java_maven.snap
index c2884d1..214dcdd 100644
--- a/tests/snapshots/generate_plan_tests__java_maven.snap
+++ b/tests/snapshots/generate_plan_tests__java_maven.snap
@@ -6,7 +6,7 @@ expression: plan
   "providers": [],
   "buildImage": "[build_image]",
   "variables": {
-    "NIXPACKS_METADATA": "Java"
+    "NIXPACKS_METADATA": "java"
   },
   "phases": {
     "build": {
diff --git a/tests/snapshots/generate_plan_tests__java_maven_wrapper.snap b/tests/snapshots/generate_plan_tests__java_maven_wrapper.snap
index c323b5a..626d865 100644
--- a/tests/snapshots/generate_plan_tests__java_maven_wrapper.snap
+++ b/tests/snapshots/generate_plan_tests__java_maven_wrapper.snap
@@ -6,7 +6,7 @@ expression: plan
   "providers": [],
   "buildImage": "[build_image]",
   "variables": {
-    "NIXPACKS_METADATA": "Java"
+    "NIXPACKS_METADATA": "java"
   },
   "phases": {
     "build": {
diff --git a/tests/snapshots/generate_plan_tests__java_spring_boot.snap b/tests/snapshots/generate_plan_tests__java_spring_boot.snap
index b7455bc..536412b 100644
--- a/tests/snapshots/generate_plan_tests__java_spring_boot.snap
+++ b/tests/snapshots/generate_plan_tests__java_spring_boot.snap
@@ -6,7 +6,7 @@ expression: plan
   "providers": [],
   "buildImage": "[build_image]",
   "variables": {
-    "NIXPACKS_METADATA": "Java"
+    "NIXPACKS_METADATA": "java"
   },
   "phases": {
     "build": {
diff --git a/tests/snapshots/generate_plan_tests__ruby.snap b/tests/snapshots/generate_plan_tests__ruby.snap
index 32e5287..f3e5efe 100644
--- a/tests/snapshots/generate_plan_tests__ruby.snap
+++ b/tests/snapshots/generate_plan_tests__ruby.snap
@@ -9,7 +9,7 @@ expression: plan
     "BUNDLE_GEMFILE": "/app/Gemfile",
     "GEM_HOME": "/usr/local/rvm/gems/ruby-3.1.2",
     "GEM_PATH": "/usr/local/rvm/gems/ruby-3.1.2:/usr/local/rvm/gems/ruby-3.1.2@global",
-    "NIXPACKS_METADATA": "Ruby"
+    "NIXPACKS_METADATA": "ruby"
   },
   "phases": {
     "install": {
diff --git a/tests/snapshots/generate_plan_tests__ruby_execjs.snap b/tests/snapshots/generate_plan_tests__ruby_execjs.snap
index 6b2f3a5..2fa7e91 100644
--- a/tests/snapshots/generate_plan_tests__ruby_execjs.snap
+++ b/tests/snapshots/generate_plan_tests__ruby_execjs.snap
@@ -9,7 +9,7 @@ expression: plan
     "BUNDLE_GEMFILE": "/app/Gemfile",
     "GEM_HOME": "/usr/local/rvm/gems/ruby-3.1.2",
     "GEM_PATH": "/usr/local/rvm/gems/ruby-3.1.2:/usr/local/rvm/gems/ruby-3.1.2@global",
-    "NIXPACKS_METADATA": "Ruby"
+    "NIXPACKS_METADATA": "ruby"
   },
   "phases": {
     "install": {
diff --git a/tests/snapshots/generate_plan_tests__ruby_local_deps.snap b/tests/snapshots/generate_plan_tests__ruby_local_deps.snap
index a8ac2f8..b9b9024 100644
--- a/tests/snapshots/generate_plan_tests__ruby_local_deps.snap
+++ b/tests/snapshots/generate_plan_tests__ruby_local_deps.snap
@@ -9,7 +9,7 @@ expression: plan
     "BUNDLE_GEMFILE": "/app/Gemfile",
     "GEM_HOME": "/usr/local/rvm/gems/ruby-3.1.2",
     "GEM_PATH": "/usr/local/rvm/gems/ruby-3.1.2:/usr/local/rvm/gems/ruby-3.1.2@global",
-    "NIXPACKS_METADATA": "Ruby"
+    "NIXPACKS_METADATA": "ruby"
   },
   "phases": {
     "install": {
diff --git a/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap b/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap
index bbd5465..24cf472 100644
--- a/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap
+++ b/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap
@@ -9,7 +9,7 @@ expression: plan
     "BUNDLE_GEMFILE": "/app/Gemfile",
     "GEM_HOME": "/usr/local/rvm/gems/3.1.2",
     "GEM_PATH": "/usr/local/rvm/gems/3.1.2:/usr/local/rvm/gems/3.1.2@global",
-    "NIXPACKS_METADATA": "Ruby",
+    "NIXPACKS_METADATA": "ruby",
     "RAILS_LOG_TO_STDOUT": "enabled"
   },
   "phases": {
diff --git a/tests/snapshots/generate_plan_tests__ruby_sinatra.snap b/tests/snapshots/generate_plan_tests__ruby_sinatra.snap
index d2ff165..4e8965e 100644
--- a/tests/snapshots/generate_plan_tests__ruby_sinatra.snap
+++ b/tests/snapshots/generate_plan_tests__ruby_sinatra.snap
@@ -9,7 +9,7 @@ expression: plan
     "BUNDLE_GEMFILE": "/app/Gemfile",
     "GEM_HOME": "/usr/local/rvm/gems/ruby-3.1.2",
     "GEM_PATH": "/usr/local/rvm/gems/ruby-3.1.2:/usr/local/rvm/gems/ruby-3.1.2@global",
-    "NIXPACKS_METADATA": "Ruby"
+    "NIXPACKS_METADATA": "ruby"
   },
   "phases": {
     "install": {
diff --git a/tests/snapshots/generate_plan_tests__ruby_with_node.snap b/tests/snapshots/generate_plan_tests__ruby_with_node.snap
index b09673c..96dc5eb 100644
--- a/tests/snapshots/generate_plan_tests__ruby_with_node.snap
+++ b/tests/snapshots/generate_plan_tests__ruby_with_node.snap
@@ -9,7 +9,7 @@ expression: plan
     "BUNDLE_GEMFILE": "/app/Gemfile",
     "GEM_HOME": "/usr/local/rvm/gems/ruby-3.1.2",
     "GEM_PATH": "/usr/local/rvm/gems/ruby-3.1.2:/usr/local/rvm/gems/ruby-3.1.2@global",
-    "NIXPACKS_METADATA": "Ruby"
+    "NIXPACKS_METADATA": "ruby"
   },
   "phases": {
     "install": {