     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)

    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"

  end

  defp has_file(filename) do
    filename |> priv_path |> File.exists?()
  end

  defp has_local_ext_file(filename) do
    filename |> project_ext_path |> File.exists?()
  end

  defp has_files? do
    has_file("appsignal-agent") and
      has_file("appsignal.h") and
      has_file("appsignal_extension.so")
  end

  defp has_local_release_files? do
    has_local_ext_file("appsignal-agent") and
      has_local_ext_file("appsignal.h") and
      has_local_ext_file("libappsignal.a")
  end

  defp has_correct_agent_version? do
    path = priv_path("appsignal.version")
    File.read(path) == {:ok, "#{Appsignal.Agent.version()}\n"}
  end

  defp clean_up_extension_files do
    priv_dir()
    |> Path.join("*appsignal*")
    |> Path.wildcard()
    |> Enum.each(&File.rm_rf!/1)
  end

  def agent_platform do
    case force_musl_build?() do
      true ->
        "linux-musl"

      false ->
        case @os.type do
          {:unix, :linux} ->
            agent_platform_by_ldd_version()

          {_, os} ->
            to_string(os)
        end
