             app_dir
           end
 
-        copy_app(app_dir, target_dir, dev_mode?, include_src?)
+        copy_app(app_name, app_dir, target_dir, dev_mode?, include_src?)
 
       _ ->
         case Utils.is_erts_lib?(app_dir) do

            :ok

          false ->
            copy_app(app_dir, target_dir, dev_mode?, include_src?)
        end
    end
  end

  defp copy_app(app_dir, target_dir, true, _include_src?) do
    case File.ln_s(app_dir, target_dir) do
      :ok ->
        :ok

  catch
    :error, {:assembler, _mod, _reason} = err ->
      {:error, err}
  end

  # Finds sources for `app_name`. This is used for applications built from
  # this project, where the source code lies in a different location than the
  # compiled files.
  defp project_app_src_dirs(app_name) do
    case project_app_src_root(app_name) do
      nil -> []
      path -> Path.wildcard(Path.join(path, "{lib,src}"))
    end
  end

  # Returns a path of the source code directory for an application built from
  # this project.
  defp project_app_src_root(app_name) do
    if not Mix.Project.umbrella?() && Mix.Project.get().project[:app] == app_name do
      # This is a top-level application.
      File.cwd!()
    else
      # This returns a directory if the app is either a dependency or an
      # application in umbrella. It returns `nil` otherwise.
      Map.get(Mix.Project.deps_paths(), app_name)
    end
  end

  # Creates release metadata files
