benoitc / erlang-idna

Erlang IDNA lib
MIT License
43 stars 29 forks source link

missing module? #16

Closed madasebrof closed 7 years ago

madasebrof commented 7 years ago

I may be doing something entirely wrong, but it looks like Idna is calling "unicode_util.lowercase", but the function doesn't exist. Obviously, it should be getting that from unicode_util_compat, but that it's in there.

Not sure where else to post! Thanks in advance for any help...

I am using Elixir 1.4.4, and am using:

{:hackney, "~> 1.8.3"},
{:httpoison, "~> 0.11.2"},
{:unicode_util_compat, "~> 0.1.0"},
{:idna, "~> 5.0.1"},
{:poison, "~> 3.1.0"}
Erlang/OTP 19 [erts-8.0] [64-bit] [smp:8:8] [async-threads:10]

/e/Dropbox/SGIM/Dev/Elixir/wiki_dream > ./wiki_dream elixir
** (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (module :unicode_util is not available)
    :unicode_util.lowercase('en.wikipedia.org')
    (idna) e:/Dropbox/SGIM/Dev/Elixir/wiki_dream/deps/idna/src/idna.erl:57: :idna.lowercase_list/1
    (idna) e:/Dropbox/SGIM/Dev/Elixir/wiki_dream/deps/idna/src/idna.erl:10: :idna.to_ascii/1
    (hackney) e:/Dropbox/SGIM/Dev/Elixir/wiki_dream/deps/hackney/src/hackney_url.erl:96: :hackney_url.normalize/2
    (hackney) e:/Dropbox/SGIM/Dev/Elixir/wiki_dream/deps/hackney/src/hackney.erl:306: :hackney.request/5
    (httpoison) lib/httpoison/base.ex:432: HTTPoison.Base.request/9
    (wiki_dream) lib/wiki_dream/fetch_json.ex:4: WikiDream.JSONFetch.fetch/1
    (elixir) lib/kernel/cli.ex:76: anonymous fn/3 in Kernel.CLI.exec_fun/2
akoutmos commented 7 years ago

It looks like unicode_util_compat was added as a dependency in the latest release 5.0.1. Not sure if related but having issues over here as well with unicode_util_compat in that it won't build my elixir project when inside the elixir:1.4.4-slim docker image. For some reason works fine on my Linux Mint desktop, but fails in the container.

The error output from running 'mix test' and trying to compile everything:

** (Mix) Could not compile dependency :unicode_util_compat, "/root/.mix/rebar3 bare compile --paths "/app/_build/test/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile unicode_util_compat", update it with "mix deps.update unicode_util_compat" or clean it with "mix deps.clean unicode_util_compat"

And the rebar3.crashdump output:

Error: {badmatch,[]}
[{rebar_prv_bare_compile,do,1,
                         [{file,"/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar_prv_bare_compile.erl"},
                          {line,45}]},
 {rebar_core,do,2,
             [{file,"/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar_core.erl"},
              {line,153}]},
 {rebar_prv_do,do_tasks,2,
               [{file,"/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar_prv_do.erl"},
                {line,68}]},
 {rebar_core,do,2,
             [{file,"/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar_core.erl"},
              {line,153}]},
 {rebar3,main,1,
         [{file,"/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar3.erl"},
          {line,66}]},
 {escript,run,2,[{file,"escript.erl"},{line,760}]},
 {escript,start,1,[{file,"escript.erl"},{line,277}]},
 {init,start_em,1,[]}]
benoitc commented 7 years ago

Hrm how can I reproduce the issue? Can you provide a clear step for it?

benoitc commented 7 years ago

I tried with a simple project, added the dependencies above and didn't reproduce it:

kv] vim mix.exs                                                       9:30:41
[kv] mix deps.get                                                      9:30:55
Running dependency resolution...
Dependency resolution completed:
  certifi 1.2.1
  hackney 1.8.3
  httpoison 0.11.2
  idna 5.0.1
  metrics 1.0.1
  mimerl 1.0.2
  poison 3.1.0
  ssl_verify_fun 1.1.1
  unicode_util_compat 0.1.0
* Getting hackney (Hex package)
  Checking package (https://repo.hex.pm/tarballs/hackney-1.8.3.tar)
  Fetched package
* Getting httpoison (Hex package)
  Checking package (https://repo.hex.pm/tarballs/httpoison-0.11.2.tar)
  Fetched package
* Getting unicode_util_compat (Hex package)
  Checking package (https://repo.hex.pm/tarballs/unicode_util_compat-0.1.0.tar)
  Fetched package
* Getting idna (Hex package)
  Checking package (https://repo.hex.pm/tarballs/idna-5.0.1.tar)
  Fetched package
* Getting poison (Hex package)
  Checking package (https://repo.hex.pm/tarballs/poison-3.1.0.tar)
  Fetched package
* Getting certifi (Hex package)
  Checking package (https://repo.hex.pm/tarballs/certifi-1.2.1.tar)
  Fetched package
* Getting metrics (Hex package)
  Checking package (https://repo.hex.pm/tarballs/metrics-1.0.1.tar)
  Fetched package
* Getting mimerl (Hex package)
  Checking package (https://repo.hex.pm/tarballs/mimerl-1.0.2.tar)
  Fetched package
* Getting ssl_verify_fun (Hex package)
  Checking package (https://repo.hex.pm/tarballs/ssl_verify_fun-1.1.1.tar)
  Fetched package
[kv] mix test                                                          9:30:58
Could not find "rebar3", which is needed to build dependency :mimerl
I can install a local copy which is just used by Mix
Shall I install rebar3? (if running non-interactively, use: "mix local.rebar --force") [Yn] y
* creating /Users/benoitc/.mix/rebar
* creating /Users/benoitc/.mix/rebar3
===> Compiling mimerl
===> Compiling metrics
===> Compiling unicode_util_compat
escript ../uc_spec/gen_unicode_mod.escript
===> Compiling idna
==> poison
Compiling 4 files (.ex)
Generated poison app
==> ssl_verify_fun (compile)
Compiled src/ssl_verify_util.erl
Compiled src/ssl_verify_fingerprint.erl
Compiled src/ssl_verify_pk.erl
Compiled src/ssl_verify_hostname.erl
===> Compiling certifi
escript ../certs_spec/gen_certifi_mod.escript
===> Compiling hackney
==> httpoison
Compiling 2 files (.ex)
Generated httpoison app
==> kv
Compiling 1 file (.ex)
Generated kv app
..

Finished in 0.04 seconds
2 tests, 0 failures

Randomized with seed 680230

Can you give me more detail on how you built it?

benoitc commented 7 years ago

forgot to add the test in the shell:

[kv] iex -S mix                                                        9:35:52
Erlang/OTP 19 [erts-8.2.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [kernel-poll:false]

Interactive Elixir (1.4.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> HTTPoison.start
{:ok, []}
iex(2)> HTTPoison.get! "http://en.wikipedia.org"
%HTTPoison.Response{body: "",
 headers: [{"Date", "Sun, 28 May 2017 07:37:49 GMT"}, {"Server", "Varnish"},
  {"X-Varnish", "465130283"}, {"X-Cache", "cp3031 int"},
  {"X-Cache-Status", "int"},
  {"Set-Cookie",
   "WMF-Last-Access=28-May-2017;Path=/;HttpOnly;secure;Expires=Thu, 29 Jun 2017 00:00:00 GMT"},
  {"Set-Cookie",
   "WMF-Last-Access-Global=28-May-2017;Path=/;Domain=.wikipedia.org;HttpOnly;secure;Expires=Thu, 29 Jun 2017 00:00:00 GMT"},
  {"X-Client-IP", "90.109.131.233"}, {"Location", "https://en.wikipedia.org/"},
  {"Content-Length", "0"}, {"Connection", "keep-alive"}], status_code: 301}
iex(3)>
madasebrof commented 7 years ago

Thanks for the reply, will re-try on Linux. (I build on Windows 10, Elixir 1.4.4, Erlang/OTP 19 [erts-8.0] [64-bit] [smp:8:8] [async-threads:10]). I swapped out HTTPoison for HTTPotion and it worked fine on my Windows box.

benoitc commented 7 years ago

ok, thanks. just noticed that you won't have IDNA support in "httppotion" or any other client.

adrienyou commented 7 years ago

I am having exactly the same issue, while running Elixir 1.4.2, Erlang/OTP 19.3 on Windows 10. I created a mix project as well and have no issue to fetch the dependencies or to compile. Here is what I have with mix.deps

Running your test gives me the same error: iex(1)> HTTPoison.start {:ok, []} iex(2)> HTTPoison.get! "http://en.wikipedia.org"

** (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (module :unicode_util is not available)

Let me know if you need more.

benoitc commented 7 years ago

how do you build it on your windows box? are you doing it i. the linux subsystem?

benoitc commented 7 years ago

@AYouEcp ping?

cc3c commented 7 years ago

Hello. I have the same issue with

Running the test: iex(1)> HTTPoison.start {:ok, [:unicode_util_compat, :idna, :mimerl, :certifi, :ssl_verify_fun, :metrics, :hackney, :httpoison]} iex(2)> HTTPoison.get! "http://en.wikipedia.org" ** (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (mod ule :unicode_util is not available) :unicode_util.lowercase('en.wikipedia.org') (idna) d:/sulia/test_phoenix/deps/idna/src/idna.erl:57: :idna.lowercase _list/1 (idna) d:/sulia/test_phoenix/deps/idna/src/idna.erl:10: :idna.to_ascii/ 1 (hackney) d:/sulia/test_phoenix/deps/hackney/src/hackney_url.erl:96: :hack ney_url.normalize/2 (hackney) d:/sulia/test_phoenix/deps/hackney/src/hackney.erl:291: :hackney .request/5 (httpoison) lib/httpoison/base.ex:432: HTTPoison.Base.request/9 (httpoison) lib/httpoison.ex:66: HTTPoison.request!/5

akoutmos commented 7 years ago

Here are some repro steps using the official elixir-slim docker image:

$ docker run -i -t elixir:1.4.4-slim /bin/sh
$ mix new app && cd app
$ mix local.hex --force
$ mix local.rebar --force
$ sed -i -e 's/\[]/[{:idna, "== 5.0.1"}]/g' mix.exs
$ mix deps.get
$ mix compile

If on the other hand you use the elixir:1.4.4 image in the first command, it works fine. I also tried this with version 5.0.2 and the same problem occurs.

adrienyou commented 7 years ago

@benoitc Sorry for the delay. Below the steps on my Windows to build the project (command prompt Windows):

mix new app cd app Go to mix.exs and modify deps: defp deps do [{:httpoison, "~> 0.11.2"}] end mix deps.get (FYI, I cleared ~/.hex/packages to make sure not to used cached version) iex -S mix (This compiles everything) HTTPoison.start HTTPoison.get! "http://en.wikipedia.org" (Same error)

Below the whole trace

>mix deps.get
Running dependency resolution...
Dependency resolution completed:
  certifi 1.2.1
  hackney 1.8.5
  httpoison 0.11.2
  idna 5.0.2
  metrics 1.0.1
  mimerl 1.0.2
  ssl_verify_fun 1.1.1
  unicode_util_compat 0.2.0
* Getting httpoison (Hex package)
  Checking package (https://repo.hex.pm/tarballs/httpoison-0.11.2.tar)
  Fetched package
* Getting hackney (Hex package)
  Checking package (https://repo.hex.pm/tarballs/hackney-1.8.5.tar)
  Fetched package
* Getting certifi (Hex package)
  Checking package (https://repo.hex.pm/tarballs/certifi-1.2.1.tar)
  Fetched package
* Getting idna (Hex package)
  Checking package (https://repo.hex.pm/tarballs/idna-5.0.2.tar)
  Fetched package
* Getting metrics (Hex package)
  Checking package (https://repo.hex.pm/tarballs/metrics-1.0.1.tar)
  Fetched package
* Getting mimerl (Hex package)
  Checking package (https://repo.hex.pm/tarballs/mimerl-1.0.2.tar)
  Fetched package
* Getting ssl_verify_fun (Hex package)
  Checking package (https://repo.hex.pm/tarballs/ssl_verify_fun-1.1.1.tar)
  Fetched package
* Getting unicode_util_compat (Hex package)
  Checking package (https://repo.hex.pm/tarballs/unicode_util_compat-0.2.0.tar)
  Fetched package

>iex -S mix
Eshell V8.3  (abort with ^G)
===> Compiling mimerl
===> Compiling metrics
===> Compiling unicode_util_compat
===> Compiling idna
==> ssl_verify_fun (compile)
Compiled src/ssl_verify_util.erl
Compiled src/ssl_verify_fingerprint.erl
Compiled src/ssl_verify_pk.erl
Compiled src/ssl_verify_hostname.erl
===> Compiling certifi
===> Compiling hackney
==> httpoison
Compiling 2 files (.ex)
Generated httpoison app
==> app
Compiling 1 file (.ex)
Generated app app
Interactive Elixir (1.4.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> HTTPoison.start
{:ok, []}
iex(2)> HTTPoison.get! "http://en.wikipedia.org"
** (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (module :unicode_util is not available)
                :unicode_util.lowercase('en.wikipedia.org')
         (idna) c:/Users/AYou/ElixirWork/app/deps/idna/src/idna.erl:57: :idna.lowercase_list/1
         (idna) c:/Users/AYou/ElixirWork/app/deps/idna/src/idna.erl:10: :idna.to_ascii/1
      (hackney) c:/Users/AYou/ElixirWork/app/deps/hackney/src/hackney_url.erl:96: :hackney_url.normalize/2
      (hackney) c:/Users/AYou/ElixirWork/app/deps/hackney/src/hackney.erl:291: :hackney.request/5
    (httpoison) lib/httpoison/base.ex:432: HTTPoison.Base.request/9
    (httpoison) lib/httpoison.ex:66: HTTPoison.request!/5
benoitc commented 7 years ago

i can't reproduce on OSX (see below the full log). However I notice that on my machine it correctly compiles the unicode_util_compat application which doesn't appear the case in your log:

===> Compiling unicode_util_compat
escript ../uc_spec/gen_unicode_mod.escript

I will try on a window machine once I figured to have a windows. Maybe there is a cache?

Full log:

[app] mix deps.get                                                    17:36:26
Running dependency resolution...
Dependency resolution completed:
  certifi 1.2.1
  hackney 1.8.6
  httpoison 0.11.2
  idna 5.0.2
  metrics 1.0.1
  mimerl 1.0.2
  ssl_verify_fun 1.1.1
  unicode_util_compat 0.2.0
* Getting unicode_util_compat (Hex package)
  Checking package (https://repo.hex.pm/tarballs/unicode_util_compat-0.2.0.tar)
  Fetched package
[app] iex -S mix                                                      17:36:45
Erlang/OTP 19 [erts-8.2.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [kernel-poll:false]

===> Compiling mimerl
===> Compiling metrics
===> Compiling unicode_util_compat
escript ../uc_spec/gen_unicode_mod.escript
===> Compiling idna
==> ssl_verify_fun (compile)
Compiled src/ssl_verify_util.erl
Compiled src/ssl_verify_fingerprint.erl
Compiled src/ssl_verify_pk.erl
Compiled src/ssl_verify_hostname.erl
===> Compiling certifi
escript ../certs_spec/gen_certifi_mod.escript
===> Compiling hackney
==> httpoison
Compiling 2 files (.ex)
Generated httpoison app
==> app
Compiling 1 file (.ex)
Generated app app
Interactive Elixir (1.4.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> HTTPoison.start
{:ok, []}
iex(2)> HTTPoison.get! "http://en.wikipedia.org"
%HTTPoison.Response{body: "",
 headers: [{"Date", "Sun, 11 Jun 2017 15:37:38 GMT"}, {"Server", "Varnish"},
  {"X-Varnish", "702440847"}, {"X-Cache", "cp3031 int"},
  {"X-Cache-Status", "int"},
  {"Set-Cookie",
   "WMF-Last-Access=11-Jun-2017;Path=/;HttpOnly;secure;Expires=Thu, 13 Jul 2017 12:00:00 GMT"},
  {"Set-Cookie",
   "WMF-Last-Access-Global=11-Jun-2017;Path=/;Domain=.wikipedia.org;HttpOnly;secure;Expires=Thu, 13 Jul 2017 12:00:00 GMT"},
  {"X-Client-IP", "90.109.131.233"}, {"Location", "https://en.wikipedia.org/"},
  {"Content-Length", "0"}, {"Connection", "keep-alive"}], status_code: 301}
bromoapp commented 7 years ago

Hi,

I don't mean to add more case in this issue, but I tried to follow this tutorial. I'm working under Win 10, with Elixir 1.4.5 and Erl 19.3.

I got:

Request: GET /auth/google/callback?code=4/Vuqfjkam1bUF3dMQDmF9s0xhu0Q0Eca1WleCtIJkG4A (exit) an exception was raised: (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (module :unicode_util is not available) :unicode_util.lowercase('www.googleapis.com') (idna) c:/Users/bromo/Documents/Projects/Git/portal/deps/idna/src/idna.erl:57: :idna.lowercase_list/1 (idna) c:/Users/bromo/Documents/Projects/Git/portal/deps/idna/src/idna.erl:10: :idna.to_ascii/1 (hackney) c:/Users/bromo/Documents/Projects/Git/portal/deps/hackney/src/hackney_url.erl:96: :hackney_url.normalize/2 (hackney) c:/Users/bromo/Documents/Projects/Git/portal/deps/hackney/src/hackney.erl:291: :hackney.request/5 (oauth2) lib/oauth2/request.ex:23: OAuth2.Request.request/6 (oauth2) lib/oauth2/client.ex:231: OAuth2.Client.get_token/4 (oauth2) lib/oauth2/client.ex:246: OAuth2.Client.get_token!/4 (ueberauth_google) lib/ueberauth/strategy/google/oauth.ex:57: Ueberauth.Strategy.Google.OAuth.get_token!/2 (ueberauth_google) lib/ueberauth/strategy/google.ex:34: Ueberauth.Strategy.Google.handle_callback!/1 (ueberauth) lib/ueberauth/strategy.ex:299: Ueberauth.Strategy.run_callback/2 (portal) web/controllers/auth_controller.ex:1: Portal.AuthController.phoenix_controller_pipeline/2 (portal) lib/portal/endpoint.ex:1: Portal.Endpoint.instrument/4 (portal) lib/phoenix/router.ex:261: Portal.Router.dispatch/2 (portal) web/router.ex:1: Portal.Router.do_call/2 (portal) lib/portal/endpoint.ex:1: Portal.Endpoint.phoenix_pipeline/1 (portal) lib/plug/debugger.ex:123: Portal.Endpoint."call (overridable 3)"/2 (portal) lib/portal/endpoint.ex:1: Portal.Endpoint.call/2 (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4 (cowboy) c:/Users/bromo/Documents/Projects/Git/portal/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/

I really hope to be able to implement google signin to my phoenix app.

Thanks

brunogirin commented 7 years ago

I initially saw that issue when building my app with distillery as distillery complains about it and fails to build a release. The error message in distillery may help getting to the bottom of this so here's the issue I raised with them: https://github.com/bitwalker/distillery/issues/294

Here's what distillery complains about:

$ mix release
==> Assembling release..
==> Building release platform:0.8.5 using environment dev
==> Release failed, during .boot generation:
        Duplicated modules: 
        unicode_util specified in stdlib and unicode_util_compat

So the app builds OK but when assembling distillery finds an issue.

I'm using Elixir 1.4.5, Erlang/OTP 20 on Ubuntu 16.04 LTS

benoitc commented 7 years ago

latest version fix that issue