dtykocki / virus_total

Elixir OTP application for the VirusTotal Public API v2.0
Other
10 stars 2 forks source link

Trying to use... error #2

Open dfischer opened 8 years ago

dfischer commented 8 years ago

I am a noob to elixir so forgive me... but I am following docs (with a valid key) and I get this:

VirusTotal.file_report(:foo, "c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31")
** (exit) exited in: GenServer.call(:foo, {:file_report, "c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31"}, 5000)
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) undefined function nil.file_report/2
            nil.file_report("126d389a1d3c816c12894e084b0a5cb8338dcdf5cc8dd1c38a63875481392b5b", "c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31")
            (virus_total) lib/virus_total.ex:85: VirusTotal.handle_call/3
            (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
            (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
            (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

00:06:52.605 [error] GenServer :foo terminating
** (UndefinedFunctionError) undefined function nil.file_report/2 (module nil is not available)
    nil.file_report("126d389a1d3c816c12894e084b0a5cb8338dcdf5cc8dd1c38a63875481392b5b", "c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31")
    (virus_total) lib/virus_total.ex:85: VirusTotal.handle_call/3
    (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:file_report, "c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31"}
State: "126d389a1d3c816c12894e084b0a5cb8338dcdf5cc8dd1c38a63875481392b5b"
    (elixir) lib/gen_server.ex:564: GenServer.call/3

Am I missing something?

defmodule SweetTooth.Mixfile do
  use Mix.Project

  def project do
    [app: :sweet_tooth,
     version: "0.0.1",
     elixir: "~> 1.2",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps]
  end

  # Configuration for the OTP application
  #
  # Type "mix help compile.app" for more information
  def application do
    [applications: [:virus_total]]
  end

  # Dependencies can be Hex packages:
  #
  #   {:mydep, "~> 0.3.0"}
  #
  # Or git/path repositories:
  #
  #   {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
  #
  # Type "mix help deps" for more examples and options
  defp deps do
    [{:virus_total, "~> 0.0.1"}]
  end
end

And I'm runnining iex -S mix in project dir.

dtykocki commented 8 years ago

@dfischer - It certainly looks like you discovered an issue. I am able to reproduce exactly what you're seeing. For some reason, the HTTP client module isn't loading correctly when included in a mix project.

I'm going to research a better solution, but you should be able to add a config entry to your config/config.ex:

config :virus_total, http_client: VirusTotal.Client

then run:

mix deps.clean --all
mix deps.get
mix deps.compile