elixir-lang / ex_doc

ExDoc produces HTML and EPUB documentation for Elixir projects
http://elixir-lang.org
Other
1.44k stars 325 forks source link

Docs fail build on first build after update from 0.20.1 to 0.21.2 #1095

Closed Hajto closed 5 years ago

Hajto commented 5 years ago

How to reproduce

Building above mentioned minimal project reproducing issue we discovered that it crashes only first time after checkout and only when there are some extras.

Additional information

We discovered this on our guide (https://github.com/membraneframework/guide). There is an error log for each extra. After second docs call it compiles fine.

Versions prior to update:

master:
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
 bunch 1.1.0
 earmark 1.3.2
 ex_doc 0.20.1
 makeup 0.8.0
 makeup_elixir 0.13.0
 membrane_core 0.3.0
 nimble_parsec 0.5.0
 qex 0.5.0

Versions after update:

Dependency resolution completed:
Unchanged:
 bunch 1.2.0
 coerce 1.0.1
 earmark 1.4.0
 ex_doc 0.21.2
 makeup 1.0.0
 makeup_elixir 0.14.0
 membrane_element_tee 0.1.0
 nimble_parsec 0.5.1
 numbers 5.1.1
 qex 0.5.0
 ratio 2.2.2

Logs:

==> nimble_parsec
Compiling 4 files (.ex)
Generated nimble_parsec app
==> makeup
Compiling 45 files (.ex)
Generated makeup app
==> coerce
Compiling 3 files (.ex)
Generated coerce app
==> bunch
Compiling 16 files (.ex)
Generated bunch app
==> numbers
Compiling 7 files (.ex)
Generated numbers app
==> earmark
Compiling 1 file (.yrl)
Compiling 2 files (.xrl)
Compiling 3 files (.erl)
Compiling 31 files (.ex)
Generated earmark app
==> makeup_elixir
Compiling 4 files (.ex)
Generated makeup_elixir app
==> ex_doc
Compiling 19 files (.ex)
warning: redefining module Mix.Tasks.Docs (current version loaded from /Users/hajtojakub/Projects/guide/_build/dev/lib/ex_doc/ebin/Elixir.Mix.Tasks.Docs.beam)
  lib/mix/tasks/docs.ex:1

Generated ex_doc app
==> ratio
Compiling 2 files (.ex)
warning: @behaviour Numeric does not exist (in module Ratio)
  lib/ratio.ex:3: Ratio (module)

10
Generated ratio app
==> membrane_core
Compiling 86 files (.ex)
Generated membrane_core app
==> membrane_element_tee
Compiling 2 files (.ex)
warning: Membrane.Element.Base.Filter.__using__/1 is deprecated. Use `Membrane.Filter` instead
  lib/membrane_element_tee/master.ex:2

Generated membrane_element_tee app
==> membrane_framework_guide
Generated membrane_framework_guide app

13:25:13.038 [error] Task #PID<0.1689.0> started from #PID<0.92.0> terminating
** (BadMapError) expected a map, got: nil
    (stdlib) :maps.find("elixir", nil)
    (makeup) lib/makeup/registry.ex:124: Makeup.Registry.fetch_lexer_by_name/1
    (ex_doc) lib/ex_doc/highlighter.ex:25: ExDoc.Highlighter.pick_language_and_lexer/1
    (ex_doc) lib/ex_doc/highlighter.ex:46: ExDoc.Highlighter.highlight_code_block/4
    (elixir) lib/regex.ex:731: Regex.apply_list/5
    (elixir) lib/regex.ex:726: Regex.apply_list/5
    (elixir) lib/regex.ex:668: Regex.do_replace/4
    (ex_doc) lib/ex_doc/formatter/html.ex:251: ExDoc.Formatter.HTML.build_extra/5
Function: &:erlang.apply/2
    Args: [#Function<1.73613889/1 in ExDoc.Formatter.HTML.build_extras/2>, ["guide/creating_app/advanced.md"]]

13:25:13.038 [error] Task #PID<0.1690.0> started from #PID<0.92.0> terminating
** (BadMapError) expected a map, got: nil
    (stdlib) :maps.find("elixir", nil)
    (makeup) lib/makeup/registry.ex:124: Makeup.Registry.fetch_lexer_by_name/1
    (ex_doc) lib/ex_doc/highlighter.ex:25: ExDoc.Highlighter.pick_language_and_lexer/1
    (ex_doc) lib/ex_doc/highlighter.ex:46: ExDoc.Highlighter.highlight_code_block/4
    (elixir) lib/regex.ex:731: Regex.apply_list/5
    (elixir) lib/regex.ex:726: Regex.apply_list/5
    (elixir) lib/regex.ex:668: Regex.do_replace/4
    (ex_doc) lib/ex_doc/formatter/html.ex:251: ExDoc.Formatter.HTML.build_extra/5
Function: &:erlang.apply/2
    Args: [#Function<1.73613889/1 in ExDoc.Formatter.HTML.build_extras/2>, ["guide/creating_app/logger.md"]]
** (EXIT from #PID<0.92.0>) an exception was raised:
    ** (BadMapError) expected a map, got: nil
        (stdlib) :maps.find("elixir", nil)
        (makeup) lib/makeup/registry.ex:124: Makeup.Registry.fetch_lexer_by_name/1
        (ex_doc) lib/ex_doc/highlighter.ex:25: ExDoc.Highlighter.pick_language_and_lexer/1
        (ex_doc) lib/ex_doc/highlighter.ex:46: ExDoc.Highlighter.highlight_code_block/4
        (elixir) lib/regex.ex:731: Regex.apply_list/5
        (elixir) lib/regex.ex:726: Regex.apply_list/5
        (elixir) lib/regex.ex:668: Regex.do_replace/4
        (ex_doc) lib/ex_doc/formatter/html.ex:251: ExDoc.Formatter.HTML.build_extra/5
josevalim commented 5 years ago

Hi @Hajto, I cannot reproduce the issue. Note that the mix.lock for master is already using ExDoc 0.21.2, but I hardcoded both ExDoc and Makeup versions and I still could not reproduce it. What Elixir version are you uisng? Have you tried the latest?

Hajto commented 5 years ago

Elixir 1.9.1 (compiled with Erlang/OTP 22)

Hajto commented 5 years ago

https://recordit.co/gn2CxO9cBR

Hajto commented 5 years ago

lock on master is locked on 0.20.1 https://github.com/bblaszkow06/ex_doc_update_crash/blob/master/mix.lock#L3

Hajto commented 5 years ago

I think this is strong hint may bo going wrong:

warning: redefining module Mix.Tasks.Docs (current version loaded from /Users/me/Projects/guide/_build/dev/lib/ex_doc/ebin/Elixir.Mix.Tasks.Docs.beam)
  lib/mix/tasks/docs.ex:1
wojtekmach commented 5 years ago

I couldn't reproduce this either. It looks like by switching branches you are switching between makeup versions and the stacktrace points to it as well. For a lack of a better answer, seems things are working on latest version? On slack you mentioned that you needed to additionally call mix deps.compile to make it work?

Hajto commented 5 years ago

I execute mix docs twice.

josevalim commented 5 years ago

Ah, good catch @Hajto. I am on Elixir master, which has a fix for this issue: https://github.com/elixir-lang/elixir/issues/9190 :) So it should be all good once a new Elixir version is out!