   end
 
   defp create_RELEASES(output_dir, relfile) do
+    Logger.debug "Generating RELEASES"
     old_cwd = File.cwd!
     File.cd!(output_dir)
     :ok = :release_handler.create_RELEASES('./', 'releases', '#{relfile}', [])

  end

  defp get_code_paths(release, output_dir) do
    get_apps(release)
    |> Enum.map(&get_app_metadata(&1, release.applications))
    |> Enum.map(fn %{name: name, version: version} ->
      lib_dir = Path.join([output_dir, "lib", "#{name}-#{version}", "ebin"])

      {:error, reason} ->
        {:error, "failed to create release directory: #{rel_dir}\n  Reason: #{reason}"}
      :ok ->
        release_file     = Path.join(rel_dir, "#{relname}.rel")
        start_clean_file = Path.join(rel_dir, "start_clean.rel")
        start_clean_rel  = %{release | :applications => [:kernel, :stdlib]}
        start_clean_apps = Enum.map(start_clean_rel.applications, &get_app_metadata(&1, release.applications))
        with :ok <- write_relfile(release_file, release, apps),
             :ok <- write_relfile(start_clean_file, start_clean_rel, start_clean_apps),
             :ok <- write_binfile(release, output_dir, rel_dir),
             :ok <- generate_relup(release, output_dir, rel_dir), do: :ok
    end
  end

