     case {File.dir?(default_tmp_dir), File.stat(default_tmp_dir)} do
       {true, {:ok, %{access: :write}}} -> default_tmp_dir
       {true, {:ok, %{access: :read_write}}} -> default_tmp_dir
-      _ -> System.tmp_dir!
-    end
-  end
-
+      _ -> System.tmp_dir!()
+    end
+  end
 
   defp priv_path(filename) do
     Path.join(priv_dir(), filename)

  end

  def ensure_downloaded(arch) do
    arch_config = Appsignal.Agent.triples[arch]

    System.put_env("LIB_DIR", priv_dir())

    if has_local_release_files?() do
      Mix.shell.info "AppSignal: Using local agent release."
      File.mkdir_p!(priv_dir())
      clean_up_extension_files()
      Enum.each(["appsignal.h", "appsignal-agent", "appsignal.version", "libappsignal.a"], fn(file) ->
        File.cp(project_ext_path(file), priv_path(file))
      end)
    else
      if has_files?() and has_correct_agent_version?() do
        :ok
      else
        if is_nil(arch_config) do
          raise Mix.Error, message: """
          No config found for architecture '#{arch}'.
          Please check http://docs.appsignal.com/support/operating-systems.html
          And inform us about this error at support@appsignal.com
          """
        end

        version = Appsignal.Agent.version
        File.mkdir_p!(priv_dir())
        clean_up_extension_files()


    case :code.priv_dir(:appsignal) do
      {:error, :bad_name} ->
        # This happens on initial compilation
        Mix.Tasks.Compile.Erlang.manifests()
        |> List.first()
        |> Path.dirname()
        |> String.trim_trailing(".mix")
        |> Path.join("priv")

      path ->
        path
        |> List.to_string()
    end
  end

  defp agent_platform_by_ldd_version do
    try do
      {output, _} = System.cmd("ldd", ["--version"], stderr_to_stdout: true)

      case String.contains?(output, "musl") do
        true ->
          "linux-musl"

        false ->
          ldd_version = List.first(Regex.run(~r/\d+\.\d+/, output))

          case Version.compare("#{ldd_version}.0", "2.15.0") do
            :lt -> "linux-musl"
            _ -> "linux"
