Consider the following scenario: 1) Install the latest version of dev-lang/erlang. In my case, it is 22.0.7 from my personal overlay, but it doesn't matter. 2) Install a package that depends on erlang. In my case, it is dev-erlang/fast_xml-1.1.37 from my personal overlay, but exact version doesn't matter. 3) Downgrade dev-lang/erlang to another major version (for example, 21). 4) Now we have to rebuild dev-erlang/fast_xml (rebuild is a MUST after major version downgrade), but rebuild fails. - fxml_gen.erl depends on fxml_gen_pt.erl - src/fxml_gen_pt.erl is compiled first, into ebin/fxml_gen_pt.beam - when compiling src/fxml_gen.erl erlang compiler tries to load fxml_gen_pt.beam to resolve dependency The problem it that it tries to load /usr/lib64/erlang/lib/fast_xml-1.1.37/ebin/fxml_gen_pt.beam instead of ./ebin/fxml_gen_pt.beam which causes the failure. As a workaround I need to completely uninstall dev-erlang/fast_xml and install it again (if the compiler doesn't find /usr/lib64/erlang/lib/fast_xml-1.1.37/ebin/fxml_gen_pt.beam, it correctly links to ./ebin/fxml_gen_pt.beam). Please note that this is a rebar issue! Compilation with rebar3 works fine! dev-erlang/fast_xml is mentioned here as an example and this issue affects another packages too. It seems that this is an issue with the old deprecated rebar2 and migration to rebar3 is needed. Rebar 2.6.4 (failure): # rebar -vv skip_deps=true compile DEBUG: Evaluating config script "/var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37/rebar.config.script" DEBUG: Consult config file "/var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37/rebar.config" DEBUG: Rebar location: "/usr/bin/rebar" DEBUG: Consult config file "/var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37/src/fast_xml.app.src" DEBUG: Available deps: [] DEBUG: Missing deps : [] DEBUG: Plugins requested while processing /var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37: [] DEBUG: Predirs: [] ==> fast_xml-1.1.37 (compile) DEBUG: Matched required ERTS version: 10.3.5.4 -> .* DEBUG: Matched required OTP release: 21 -> .* DEBUG: Min OTP version unconfigured DEBUG: erl_opts [debug_info,debug_info,nowarn_export_all,{src_dirs,["src"]}] DEBUG: Files to compile first: ["src/fxml_gen_pt.erl"] Compiled src/fxml_gen_pt.erl DEBUG: Starting 3 compile worker(s) Compiled src/fxmlrpc_codec_external.erl Compiled src/fast_xml.erl Compiled src/fxml_stream.erl Compiled src/fxmlrpc.erl Compiled src/fxml.erl Compiled src/fxml_sup.erl DEBUG: Worker exited cleanly =ERROR REPORT==== 16-Aug-2019::14:46:51.802221 === Loading of /usr/lib64/erlang/lib/fast_xml-1.1.37/ebin/fxml_gen_pt.beam failed: badfile =ERROR REPORT==== 16-Aug-2019::14:46:51.802194 === beam/beam_load.c(1878): Error loading module fxml_gen_pt: This BEAM file was compiled for a later version of the run-time system than 21. To fix this, please recompile this module with an 21 compiler. (Use of opcode 164; this emulator supports only up to 163.) src/fxml_gen.erl:none: undefined parse transform 'fxml_gen_pt' Compiling src/fxml_gen.erl failed: DEBUG: Worker compilation failed: {{error, {error, [["src/fxml_gen.erl:none: undefined parse transform 'fxml_gen_pt'\n"]], []}}, {source,"src/fxml_gen.erl"}} ERROR: compile failed while processing /var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37: rebar_abort Rebar 3 (tried both 3.6.2 and 3.11.1 - successful compilation): # ./rebar3 compile ===> Fetching rebar3_hex v6.8.0 ===> Downloaded package, caching at /root/.cache/rebar3/hex/hexpm/packages/rebar3_hex-6.8.0.tar ===> Fetching hex_core v0.5.0 ===> Downloaded package, caching at /root/.cache/rebar3/hex/hexpm/packages/hex_core-0.5.0.tar ===> Fetching verl v1.0.1 ===> Downloaded package, caching at /root/.cache/rebar3/hex/hexpm/packages/verl-1.0.1.tar ===> Compiling verl ===> Compiling hex_core ===> Compiling rebar3_hex ===> Fetching pc v1.10.0 ===> Downloaded package, caching at /root/.cache/rebar3/hex/hexpm/packages/pc-1.10.0.tar ===> Compiling pc ===> Verifying dependencies... ===> Compiling fast_xml ===> Compiling /var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37/c_src/fxml.c ===> Compiling /var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37/c_src/fxml_stream.c ===> Linking /var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37/priv/lib/fxml.so ===> Linking /var/tmp/portage/dev-erlang/fast_xml-1.1.37/work/fast_xml-1.1.37/priv/lib/fxml_stream.so
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=be58acd32874f252126924678824c1316c1e3d39 commit be58acd32874f252126924678824c1316c1e3d39 Author: Petr Vaněk <arkamar@atlas.cz> AuthorDate: 2019-11-28 12:47:20 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2019-12-07 13:46:50 +0000 dev-util/rebar: subscribe to dev-lang/erlang subslot Bug: https://bugs.gentoo.org/661080 Bug: https://bugs.gentoo.org/661126 Bug: https://bugs.gentoo.org/692294 Bug: https://bugs.gentoo.org/700260 Package-Manager: Portage-2.3.76, Repoman-2.3.16 Signed-off-by: Petr Vaněk <arkamar@atlas.cz> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> dev-util/rebar/rebar-2.6.4.ebuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)