blt / port_compiler

A rebar3 port compiler
MIT License
65 stars 38 forks source link

Build fails on OTP 27 #82

Closed slashmili closed 4 months ago

slashmili commented 4 months ago

I noticed that the build is failing on OTP 27

my env:

erl
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1]

my rebar.config:

{plugins, [pc]}.
{erl_opts, [debug_info]}.
{deps, []}.

{shell, [
  % {config, "config/sys.config"},
    {apps, [myapp]}
]}.
DEBUG=1 rebar3 compile
===> Fetching pc v1.14.0
===> Making request to get package pc from repo hexpm (#{name => <<"hexpm">>,repo_verify_origin => true,
         repo_name => <<"hexpm">>,repo_url => <<"https://repo.hex.pm">>,
         repo_organization => undefined,api_url => <<"https://hex.pm/api">>,
         repo_verify => true})
===> Version cached at /Users/milad/.cache/rebar3/hex/hexpm/packages/pc-1.14.0.tar is up to date, reusing it
===> Compile (apps)
===> Running hooks for compile in app pc (/private/tmp/myapp/_build/default/plugins/pc) with configuration:
===>    {pre_hooks, []}.
===> Running hooks for erlc_compile in app pc (/private/tmp/myapp/_build/default/plugins/pc) with configuration:
===>    {pre_hooks, []}.
===> Analyzing applications...
===> Compiling pc
===> compile options: {erl_opts, [debug_info,inline_list_funcs,
                                         warn_deprecated_function,
                                         warn_export_all,warn_export_vars,
                                         warn_obsolete_guard,warn_shadow_vars,
                                         warn_untyped_record,
                                         warn_unused_function,
                                         warn_unused_import,
                                         warnings_as_errors]}.
===> files to analyze ["/private/tmp/myapp/_build/default/plugins/pc/src/pc_port_specs.erl",
                              "/private/tmp/myapp/_build/default/plugins/pc/src/pc_compilation.erl",
                              "/private/tmp/myapp/_build/default/plugins/pc/src/pc_util.erl",
                              "/private/tmp/myapp/_build/default/plugins/pc/src/pc_prv_compile.erl",
                              "/private/tmp/myapp/_build/default/plugins/pc/src/pc_prv_clean.erl",
                              "/private/tmp/myapp/_build/default/plugins/pc/src/pc_port_env.erl",
                              "/private/tmp/myapp/_build/default/plugins/pc/src/pc.erl"]
===>      Compiled pc.erl
===>      Compiled pc_prv_compile.erl
===>      Compiled pc_prv_clean.erl
===>      Compiled pc_util.erl
===>      Compiled pc_port_specs.erl
===>      Compiled pc_compilation.erl
===> Compiling _build/default/plugins/pc/src/pc_port_env.erl failed
_build/default/plugins/pc/src/pc_port_env.erl:190:10: code:lib_dir/2 is deprecated; this functionality will be removed in a future release

===> throw rebar_abort [{rebar_utils,abort,0,
                                [{file,
                                  "/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_utils.erl"},
                                 {line,729}]},
                               {rebar_parallel,parallel_dispatch,4,
                                [{file,
                                  "/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_parallel.erl"},
                                 {line,170}]},
                               {rebar_parallel,parallel_dispatch,4,
                                [{file,
                                  "/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_parallel.erl"},
                                 {line,174}]},
                               {rebar_compiler,run,4,
                                [{file,
                                  "/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_compiler.erl"},
                                 {line,261}]},
                               {lists,foreach_1,2,
                                [{file,"lists.erl"},{line,2310}]},
                               {rebar_prv_compile,
                                '-build_rebar3_apps/3-lc$^0/1-0-',3,
                                [{file,
                                  "/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_prv_compile.erl"},
                                 {line,374}]},
                               {rebar_prv_compile,build_rebar3_apps,3,
                                [{file,
                                  "/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_prv_compile.erl"},
                                 {line,389}]},
                               {rebar_prv_compile,run_compilers,4,
                                [{file,
                                  "/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_prv_compile.erl"},
                                 {line,192}]}]
===> Errors loading plugin pc. Run rebar3 with DEBUG=1 set to see errors.
v0idpwn commented 4 months ago

Seems to be fixed in pc v1.15 by #80

slashmili commented 4 months ago

I see, the question comes to my mind is why rebar is fetching v1.14.0 ? Is there another configuration/version update needs to be done for rebar to get v1.15.0?

This is the rebar I'm using

rebar3 version
rebar 3.23.0 on Erlang/OTP 27 Erts 15.0
badlop commented 4 months ago

why rebar is fetching v1.14.0 ?

Maybe:

  1. your rebar3 fetched pc some weeks ago, when the latest one was 1.14.
  2. right now, you tell rebar3 to install pc without specifying which version you want
  3. rebar3 first looks in $HOME/.cache/rebar3/hex/hexpm/packages and finds that there's pc 1.14 already downloaded, and uses that one... why not?

If that's your case, some ideas:

slashmili commented 4 months ago

This is my cache dir

$ ls -rf -l $HOME/.cache/rebar3/hex/hexpm/
total 0
drwxr-xr-x  2 milad  staff   64 25 Jun 14:50 ./
drwxr-xr-x  4 milad  staff  128 13 Jun 10:42 ../

seems like that upgrade command did the trick.

$ rebar3 plugins upgrade --all
===> Fetching pc v1.14.0
===> Analyzing applications...
===> Compiling pc
===> Compiling _build/default/plugins/pc/src/pc_port_env.erl failed
_build/default/plugins/pc/src/pc_port_env.erl:190:10: code:lib_dir/2 is deprecated; this functionality will be removed in a future release

===> Errors loading plugin pc. Run rebar3 with DEBUG=1 set to see errors.
===> Upgrading pc v1.15.0
===> Analyzing applications...
===> Compiling pc

The issue is that I'm using snappyer and in that package, the pc version is not pinned in the plugins settings.

Thanks for the hint!