jelly-beam / rebar3_ex_doc

rebar3 plugin for generating docs with ex_doc
Apache License 2.0
43 stars 13 forks source link

** (RuntimeError) could not find source or debug info for :certifi #97

Closed kianmeng closed 3 months ago

kianmeng commented 3 months ago

ENV:

$ rebar3 --version
rebar 3.23.0 on Erlang/OTP 27 Erts 15.0

Steps to reproduce:

git clone https://github.com/certifi/erlang-certifi.git
cd erlang-certifi
rebar3 ex_doc
===> Fetching rebar3_hex v7.0.8
===> Fetching hex_core v0.10.1
===> Fetching verl v1.1.1
===> Analyzing applications...
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Fetching rebar3_ex_doc v0.2.23
===> Analyzing applications...
===> Compiling rebar3_ex_doc
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling certifi
===> Running edoc for certifi
===> Running ex_doc for certifi
===> ** (RuntimeError) could not find source or debug info for :certifi
    (ex_doc 0.32.2) lib/ex_doc/language/source.ex:148: ExDoc.Language.Source.fetch_basedir!/2
    (ex_doc 0.32.2) lib/ex_doc/language/erlang.ex:29: ExDoc.Language.Erlang.module_data/3
    (ex_doc 0.32.2) lib/ex_doc/retriever.ex:85: ExDoc.Retriever.get_module/2
    (ex_doc 0.32.2) lib/ex_doc/retriever.ex:54: anonymous fn/3 in ExDoc.Retriever.docs_from_modules/3
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_doc 0.32.2) lib/ex_doc/retriever.ex:23: ExDoc.Retriever.docs_from_dir/2
    (ex_doc 0.32.2) lib/ex_doc.ex:24: ExDoc.generate_docs/3
    (ex_doc 0.32.2) lib/ex_doc/cli.ex:69: anonymous fn/6 in ExDoc.CLI.generate/3

===>

Checking the ExDoc source code indicates that this should not happen?

https://github.com/elixir-lang/ex_doc/blob/ed0ffcdece145e2703eb306890f8505bba9eecbd/lib/ex_doc/language/source.ex#L146-L148

paulo-ferraz-oliveira commented 3 months ago

I can confirm the issue shows up. Don't know how much the plugin is involved, though.

Edit: I get this, in Elixir, by just importing the latest :certifi as a dep.

iex(1)> :certifi.module_info()
[
  module: :certifi,
  exports: [cacertfile: 0, cacerts: 0, module_info: 0, module_info: 1],
  attributes: [vsn: [92827427883308776878199707187206939035]],
  compile: [version: ~c"8.5"],
  md5: <<69, 213, 233, 140, 161, 61, 90, 241, 164, 158, 213, 84, 138, 135, 225,
    155>>
]

~Edit: when I do use debug_info, importing in mix.exs via path:, I get much more stuff.~

Edit: also check this out - https://github.com/elixir-lang/ex_doc/issues/1881 (I now think this is the cause for the issue)

kianmeng commented 3 months ago

Switching to another machine, I now encountered another issue. If we're using older Rebar3, in this case, 3.22.1, the rebar3_ex_doc will use the previous version of v0.2.14.

ENV:

$ rebar3 --version
rebar 3.22.1 on Erlang/OTP 27 Erts 15.0

Steps to reproduce:

git clone https://github.com/certifi/erlang-certifi.git
cd erlang-certifi
rebar3 ex_doc
$ rebar3 ex_doc
===> Fetching rebar3_hex v7.0.2
===> Fetching hex_core v0.8.4
===> Fetching verl v1.1.1
===> Analyzing applications...
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Fetching rebar3_ex_doc v0.2.14
===> Analyzing applications...
===> Compiling rebar3_ex_doc
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling certifi
===> Running edoc for certifi
===> Running ex_doc for certifi
===> ERROR! Failed to start Elixir.
error: {error,
           {elixir,
               {bad_return,
                   {{elixir,start,[normal,[]]},
                    {'EXIT',
                        {undef,
                            [{elixir,start,[normal,[]],[]},
                             {application_master,start_it_old,4,
                                 [{file,"application_master.erl"},
                                  {line,295}]}]}}}}}}

===>
paulo-ferraz-oliveira commented 3 months ago

will use the previous version of v0.2.14

It's not rebar3_ex_doc that chooses itself a version to run, so there's something fishy going on here.

Edit: I'm gonna compile rebar3 locally on OTP 27.0 and then do the same "git clone + rebar3 ex_doc" dance on certifi 😄 (you may be on to something, I just don't yet know what...)

Edit: @kianmeng, did you, by chance, not clear _build if it was there? (it'd explain why the plugins was not updated, I think). I got this

➜  erlang-certifi git:(master) rebar3 version
                               ^ this attempts at compiling directly
===> Fetching rebar3_hex v7.0.8
===> Fetching hex_core v0.10.1
===> Fetching verl v1.1.1
===> Analyzing applications...
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Fetching rebar3_ex_doc v0.2.23
                            ^ "good" version
===> Analyzing applications...
===> Compiling rebar3_ex_doc
rebar 3.22.1 on Erlang/OTP 27 Erts 15.0
      ^ same as you (?)
➜  erlang-certifi git:(master) rebar3 ex_doc
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling certifi
===> Running edoc for certifi
===> Running ex_doc for certifi
===> ** (RuntimeError) could not find source or debug info for :certifi
    (ex_doc 0.32.2) lib/ex_doc/language/source.ex:148: ExDoc.Language.Source.fetch_basedir!/2
    (ex_doc 0.32.2) lib/ex_doc/language/erlang.ex:29: ExDoc.Language.Erlang.module_data/3
    (ex_doc 0.32.2) lib/ex_doc/retriever.ex:85: ExDoc.Retriever.get_module/2
    (ex_doc 0.32.2) lib/ex_doc/retriever.ex:54: anonymous fn/3 in ExDoc.Retriever.docs_from_modules/3
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_doc 0.32.2) lib/ex_doc/retriever.ex:23: ExDoc.Retriever.docs_from_dir/2
    (ex_doc 0.32.2) lib/ex_doc.ex:24: ExDoc.generate_docs/3
    (ex_doc 0.32.2) lib/ex_doc/cli.ex:69: anonymous fn/6 in ExDoc.CLI.generate/3

===>

In this case, again, I remove _build, the deterministic flag and rebar3_ex_doc works with no issue.

kianmeng commented 3 months ago

@paulo-ferraz-oliveira I think you're right!

I repeated the steps again from scratch again and it did get the latest rebar3_ex_doc (v0.2.23) for rebar3 (v3.22.1).

I'm now able to generate doc using ex_doc after removal of deterministic flag. Thanks a lot!