small medium large xlarge

25 Oct 2013, 03:43
Rick DeNatale (12 posts)

Working through the chapter.

I think I’ve followed everything, but when I run idx -S mix

ex(1)> Issues.GithubIssues.fetch("elixir-lang", "elixir") ** (UndefinedFunctionError) undefined function: Issues.GithubIssues.fetch/2 Issues.GithubIssues.fetch("elixir-lang", "elixir") erl_eval.erl:569: :erl_eval.do_apply/6 src/elixir.erl:138: :elixir.eval_forms/3

Which is the same problem which was given to solve at the end to section 12.5.

There seems to be something needed in the application configuration to get lib/issues/github_issues.exs recognized and compiled.

If I issue the command

c "lib/issues/github_issues.exs"

before I do Issues.GithubIssues.fetch("elixir-lang", "elixir") then it does work, but this produces a file Elixir.issues.GithubIssues.beam in the top level directory of the project, while the other beam files are in the ebin directory. Neither this nor the “need” to manually compile this file seems right, but I can’t figure out how I’m supposed to do this.

I also notice that the file name for this file is given on page 130 as “project/1/issues/lib/issues/github_issues.ex” Is this supposed to be .exs ? I tried both ways but .ex didn’t work

Mac 128k logic board 96x96_pragsmall
25 Oct 2013, 11:47
Roger T (7 posts)

All files in my /lib/issues/ directory are .ex, with .exs only for the top level mix.exs and the files in /test/

I decided to try the Erlang inets/httpc library referenced on page 128, so my github_issues.ex is:

  defmodule Issues.GithubIssues do

    @user_agent [ { 'User-agent', 'Elixir ...' } ]

    def fetch(user, project) do
      case {:ok, {{_version, status, _reasonPhrase}, _headers, body}} =
      :httpc.request(:get, {issues_url(user, project), @user_agent}, [], [body_format: :binary]) do
        {:ok, {{_, 200, _}, _, _}} ->
          { :ok, body }
        _ ->
          { :error, body }

    def issues_url(user, project),
      do: '{user}/#{project}/issues'


which required

  def application do
    [ mod: { Issues, [] },
      applications: [ :inets, :ssl ]

in mix.exs

26 Oct 2013, 19:28
Rick DeNatale (12 posts)

Thanks Roger. I changed the filetype to .ex and it now works.