Programming Elixir chapter 13 problem

Hi, I am new to Elixir.I am learning elixir by reading Programming Elixir.I got trouble when I build a simple client and try to fetch issues from github.
I did follow step in book:

$ iex -S mix
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10]...
==> idna (compile)
Compiled idna
Compiled mimerl
: :
Generated issues app

and when I type Issues.GithubIssues.fetch("elixir-lang", "elixir") it should show follow stuff:

report erratum • discuss
Task: Use Libraries • 149Let’s try it out:
iex> Issues.GithubIssues.fetch("elixir-lang", "elixir")
\"title\":\"#put_in function with structs raises

but I got a mistake like this:

Eshell V8.3  (abort with ^G)
Compiling 3 files (.ex)
Generated issues app
Interactive Elixir (1.4.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Issues.GithubIssues.fetch("elixir-lang", "elixir")
** (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (module                 :unicode_util is not available)
     (idna) f:/study/learnElixir/issues/deps/idna/src/idna.erl:57: :idna.lowercase_list/1
     (idna) f:/study/learnElixir/issues/deps/idna/src/idna.erl:10: :idna.to_ascii/1
  (hackney) f:/study/learnElixir/issues/deps/hackney/src/hackney_url.erl:96: :hackney_url.normalize/2
  (hackney) f:/study/learnElixir/issues/deps/hackney/src/hackney.erl:291: :hackney.request/5
(httpoison) lib/httpoison/base.ex:432: HTTPoison.Base.request/9
   (issues) lib/issues/github_issues.ex:6: Issues.GithubIssues.fetch/2

I really don’t know how to fix unicode_util.lowercase function.So I really appreciate your suggestions.

I believe this is a bug in a recent hackney release, see

it is fixed so if you do mix deps.update hackney you should be flying again.

1 Like

Thanks for your advice, I see your given issue and update hackney,then I try again,but still get same mistake. I think maybe this is environment problem. So I decide try this project on centos7 instead win10, and see what happened.Very appreciate your help.

my dps:

%{"certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "hexpm"},
  "hackney": {:hex, :hackney, "1.8.5", "56025cf08aaf0998a5ad6494888a069fc3800f60eb6bdd1fca7adf0f1329c888", [:rebar3], [{:certifi, "1.2.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.0.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
    "httpoison": {:hex, :httpoison, "0.11.2", "9e59f17a473ef6948f63c51db07320477bad8ba88cf1df60a3eee01150306665", [:mix], [{:hackney, "~> 1.8.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
    "idna": {:hex, :idna, "5.0.2", "ac203208ada855d95dc591a764b6e87259cb0e2a364218f215ad662daa8cd6b4", [:rebar3], [{:unicode_util_compat, "0.2.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
    "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
    "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
    "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
    "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},
    "unicode_util_compat": {:hex, :unicode_util_compat, "0.2.0", "dbbccf6781821b1c0701845eaf966c9b6d83d7c3bfc65ca2b78b88b8678bfa35", [:rebar3], [], "hexpm"}}

Having the same issue today whilst trying to use HTTPoison:

iex(1)> HTTPoison.get("")
** (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (module :unicode_util is not available)
    c:/_projects/now_playing/deps/idna/src/idna.erl:57: :idna.lowercase_list/1
    c:/_projects/now_playing/deps/idna/src/idna.erl:10: :idna.to_ascii/1
    c:/_projects/now_playing/deps/hackney/src/hackney_url.erl:96: :hackney_url.normalize/2
    c:/_projects/now_playing/deps/hackney/src/hackney.erl:291: :hackney.request/5
    lib/httpoison/base.ex:432: HTTPoison.Base.request/9

Tried updating to the latest hackney, which didn’t work

looks to be an issue - notice you are both on windows… what erlang/otp version are you on @themarlzy ?

:unicode_util.lowercase('') should work in iex with latest hackney

suppose a mix deps.compile --force never hurts - but I don’t have windows nor otp18 so can’t try and replicate.

Can confirm that this is an issue I am seeing as well.

Trying todo OAuth using ueberauth and I am having the (module :unicode_util is not available) error too.

I am running on a Windows 10 machine.


I have the same issue on my windows 7 box. On my mac, the same project works like a charm. I digged a little bit and things are not that fun on the windows front: simply put, httpoison dependencies are not compiled on windows.

There is hope : hacking a little, you can make things work. Here is what I have done:

  • in deps\unicode_util_compat\rebar.config.script, I added a new pre_hook for win32 and win64 (I really don’t know if the win64 target system really exists…) to compile it. I have something like this:
                  {"(freebsd|openbsd)", compile, "gmake -C uc_spec all"},
    		  {"(win32|win64)", compile, "make -C uc_spec all"}]
    		  } | CONFIG]
  • in deps\certifi\rebar.config, I added a similar pre_hook:
             {"(freebsd|openbsd)", compile, "gmake -C certs_spec all"},
    	     {"(win32|win64)", compile, "make -C certs_spec all"}
  • run mix deps.compile --force

If your system does not have make available, you’ll need to install it, ever from GnuWin32 or from MinGW/MSYS. I chose the first because google gave it to me first.

This made the job on my machine. It’s already a dev machine, so I may already have installed tools you’ll need to make it work on yours. Note that I hardly know what I’m doing here, I’m also at chapter 13 of the book :smile:

I’ll open a issue on those projects to see if the author can do something less ugly, or at least more documented.


I can verify that this did indeed fix the issue at hand. Kind of a bummer that it requires additional install of GnuWin32 to get it to work correctly.

Hopefully it can get resolved in an easier fashion.


fixed the issue
thank you!

I have found another way to make the sample work on windows, port to using HTTPotion from HTTPoison.

Here is a repo containing the chapter 13 sample just before adding the json support code:

Hello, the underlying issues have been solved, thanks to a PR by Ferd. It should now work without all those trouble.

1 Like

Is this issue fixed in hackney? or someplace else?

There were 2 issues on two projects (same maintainer as hackney):

certifi is used directly in hackney.
unicode_util_compat is used in idna which is itself used in hackney.