AdRoll / rebar3_format

Erlang Formatter for Rebar3
https://tech.nextroll.com/blog/dev/2020/02/25/erlang-rebar3-format.html
MIT License
108 stars 21 forks source link

undefined function ktn_dodger:parse_file/2 #330

Closed Olivier-Boudeville closed 1 year ago

Olivier-Boudeville commented 1 year ago

Hi,

I was unable to build rebar3_format properly from a fresh, unchanged clone (with Erlang 25.1 on Arch Linux, if it matters):

$ git clone https://github.com/AdRoll/rebar3_format.git
Cloning into 'rebar3_format'...
remote: Enumerating objects: 2446, done.
remote: Counting objects: 100% (535/535), done.
remote: Compressing objects: 100% (184/184), done.
remote: Total 2446 (delta 447), reused 359 (delta 351), pack-reused 1911
Receiving objects: 100% (2446/2446), 750.70 KiB | 202.00 KiB/s, done.
Resolving deltas: 100% (1703/1703), done.

Then:

$ cd rebar3_format
$ rebar3 compile
===> 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_hank v1.3.0
===> Fetching katana_code v2.0.0
===> Analyzing applications...
===> Compiling katana_code
===> Compiling rebar3_hank
===> Fetching rebar3_lint v2.0.0
===> Fetching elvis_core v2.0.0
===> Fetching zipper v1.0.1
===> Analyzing applications...
===> Compiling zipper
===> Compiling katana_code
===> Compiling elvis_core
===> Compiling rebar3_lint
===> Fetching rebar3_sheldon v0.4.2
===> Fetching sheldon v0.4.1
===> Fetching worker_pool v5.1.0
===> Analyzing applications...
===> Compiling worker_pool
===> Compiling sheldon
===> Compiling rebar3_sheldon
===> Fetching rebar3_ex_doc v0.2.14
===> Analyzing applications...
===> Compiling rebar3_ex_doc
===> Verifying dependencies...
===> Fetching katana_code v2.0.0
===> Analyzing applications...
===> Compiling katana_code
===> Analyzing applications...
===> Compiling rebar3_format
escript: exception error: undefined function ktn_dodger:parse_file/2
  in function  rebar3_ast_formatter:format/3 (EDITED/Software/rebar3_format/src/rebar3_ast_formatter.erl, line 17)
  in call from lists:foreach_1/2 (lists.erl, line 1442)
  in call from erl_eval:local_func/8 (erl_eval.erl, line 644)
  in call from escript:interpret/4 (escript.erl, line 780)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_em/1 
  in call from init:do_boot/3 
===> Hook for compile failed!

I tried also to remove ~/.cache/rebar/hex and ~/.cache/rebar3/ with no luck.

Thanks!

elbrujohalcon commented 1 year ago

OTP25, right? You need to enable the new compiler features as explained in #314.

ERL_FLAGS="-enable-feature all" rebar3 format
Olivier-Boudeville commented 1 year ago

Thanks Brujo, that did indeed the trick, both as: ERL_FLAGS="-enable-feature all" rebar3 format and as ERL_FLAGS="-enable-feature all" rebar3 as release escriptize

I expect it to become a pretty common error that will be reported again and again, maybe there would be a way of adding that flag automatically or at least check that the maybe feature is available when running rebar3 in this context?

Anyway I close this issue as this is fixed for me. Thanks again!