             priv_dir: "",
             skip_compilation?: false,
             target: nil,
-            target_dir: ""
+            target_dir: "",
+            metadata: nil
 
   alias Rustler.Compiler.Config
 

          raise "calling `cargo metadata` failed.\n" <> output
      end

    json = Jason.decode!(metadata)

    packages = json["packages"]

    crate_spec = get_spec(packages, crate_str)

    packages

  end

  defp build(opts) do
    opts =
      if opts[:skip_compilation?] do
        opts
      else
        crate = Keyword.fetch!(opts, :crate)
        crate_path = Keyword.fetch!(opts, :path)

        metadata = metadata!(crate_path)
        resources = external_resources(crate_path, crate, metadata)

        opts
        |> Keyword.put(:metadata, metadata)
        |> Keyword.put(:external_resources, resources)
      end

    struct!(Config, opts)
  end

  defp metadata!(crate_path) do
    metadata =
      case System.cmd("cargo", ~w(metadata --format-version=1), cd: crate_path) do
        {metadata, 0} ->
