rebar3



Build better Erlang.

Ask A Question

Questions

4
ANSWERED

iolist_to_binary failing within bbmustache

Hi, (using latest rebar3 from GIT, run with DEBUG=1) When attempting to generate a release (I think I am quite close to success), I found out that bbmustache was failing when trying to process following part of my rebar.config: {erl_opts, [ {d,myriad_debug_mode}, debug_info, {debug_info_key,"Ceylan-Myriad"}, report_warnings, warn_export_all, warn_export_vars, warn_shadow_vars, warn_obsolete_guards, warn_unused_import, warnings_as_errors, {parse_transform,myriad_parse_transform}, {i,"include/data-management"}, {i,"include/maths"}, {i,"include/meta"}, {i,"include/user-interface/src"}, {i,"include/user-interface/src/textual"}, {i,"include/user-interface/src/graphical"}, {i,"include/utils"}, {i,"include/scripts"}, {i,"include/apps/merge-tool"} ]}, (although I do not see what could be wrong there?) Here is the detailed stack trace (apparently there is a type mismatch, maybe a proplist where an iolist was expected?): (for that I had to modify a bit rebar, namely rlx_util.erl, as otherwise it was just spitting 'render_failed' with no further information; so: render(Template, Data) when is_binary(Template) -> case catch bbmustache:render(Template, Data, [{key_type, atom}]) of Bin when is_binary(Bin) -> {ok, Bin}; _ -> {error, render_failed} end. became a clearer: render(Template, Data) when is_binary(Template) -> case catch bbmustache:render(Template, Data, [{key_type, atom}]) of Bin when is_binary(Bin) -> {ok, Bin}; E -> io:format( "~nRENDER FAILED: ~p~n", [ E ] ), {error, render_failed} end. ) resulting in following error / stack trace: RENDER FAILED: {'EXIT', {badarg, [{erlang,iolist_to_binary, [[{d,myriad_debug_mode}, debug_info, {debug_info_key,"Ceylan-Myriad"}, report_warnings,warn_export_all,warn_export_vars, warn_shadow_vars,warn_obsolete_guards, warn_unused_import,warnings_as_errors, {parse_transform,myriad_parse_transform}, {i,"include/data-management"}, {i,"include/maths"}, {i,"include/meta"}, {i,"include/user-interface/src"}, {i,"include/user-interface/src/textual"}, {i,"include/user-interface/src/graphical"}, {i,"include/utils"}, {i,"include/scripts"}, {i,"include/apps/merge-tool"}]], []}, {bbmustache,compile_impl,4, [{file, "EDITED/Software/rebar3/_build/default/lib/bbmustache/src/bbmustache.erl"}, {line,233}]}, {bbmustache,compile,3, [{file, "EDITED/Software/rebar3/_build/default/lib/bbmustache/src/bbmustache.erl"}, {line,218}]}, {rlx_util,render,2, [{file, "EDITED/Software/rebar3/_build/default/lib/relx/src/rlx_util.erl"}, {line,177}]}, {rlx_prv_assembler,render,2, [{file, "EDITED/Software/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"}, {line,922}]}, {rlx_prv_assembler,write_bin_file,4, [{file, "EDITED/Software/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"}, {line,421}]}, {rlx_prv_assembler,do,1, [{file, "EDITED/Software/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"}, {line,59}]}, {relx,run_provider,2, [{file, "EDITED/Software/rebar3/_build/default/lib/relx/src/relx.erl"}, {line,309}]}]}} ===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump ===> Uncaught error: {badmatch,{error,render_failed}} ===> Stack trace to the error location: [{rlx_prv_assembler,render,2, [{file,"EDITED/Software/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"}, {line,922}]}, {rlx_prv_assembler,write_bin_file,4, [{file,"EDITED/Software/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"}, {line,421}]}, {rlx_prv_assembler,do,1, [{file,"EDITED/Software/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"}, {line,59}]}, {relx,run_provider,2, [{file,"EDITED/Software/rebar3/_build/default/lib/relx/src/relx.erl"}, {line,309}]}, {lists,foldl,3,[{file,"lists.erl"},{line,1263}]}, {relx,run_providers_for_actions,2, [{file,"EDITED/Software/rebar3/_build/default/lib/relx/src/relx.erl"}, {line,292}]}, {relx,main,2, [{file,"EDITED/Software/rebar3/_build/default/lib/relx/src/relx.erl"}, {line,65}]}, {rebar_relx,do,4, [{file,"EDITED/Software/rebar3/src/rebar_relx.erl"}, {line,45}]}] Any hint would be greatly appreciated! Thanks in advance, Olivier.

Posted by Olivier Boudeville about a month ago

4

Failing to publish an hex package thanks to rebar3

Hi, I have an Erlang/OTP library application / release (namely myriad, i.e. https://github.com/Olivier-Boudeville/Ceylan-Myriad) that I try to integrate as an hex package thanks to rebar3. I tried to follow the guidelines in https://www.rebar3.org/docs/publishing-packages and https://www.rebar3.org/docs/hex-package-management but with not much luck. I have an account at hex.pm and tried to set up everything properly (outputs edited so that real info are replaced with MY_* placeholders): $ rebar3 hex user whoami hexpm : MY_HEX_LOGIN (MY_EMAIL_ADDRESS) (looks ok) $ rebar3 hex key list ===> Fetching rebar3_hex v6.7.0 ===> Version cached at /home/MY_USER/.cache/rebar3/hex/hexpm/packages/rebar3_hex-6.7.0.tar is up to date, reusing it ===> Fetching hex_core v0.5.0 ===> Version cached at /home/MY_USER/.cache/rebar3/hex/hexpm/packages/hex_core-0.5.0.tar is up to date, reusing it ===> Fetching verl v1.0.1 ===> Version cached at /home/MY_USER/.cache/rebar3/hex/hexpm/packages/verl-1.0.1.tar is up to date, reusing it ===> Compiling verl ===> Compiling hex_core ===> Compiling rebar3_hex Name Created MY_COMPUTER 2019-07-14T14:39:40Z MY_COMPUTER-api-read 2019-07-14T14:39:40Z MY_COMPUTER-repositories 2019-07-14T14:39:40Z (looks ok) $ rebar3 hex owner list myriad $ rebar3 hex owner add myriad MY_EMAIL_ADDRESS Local Password: $ rebar3 hex owner list myriad (so: still nothing) $ rebar3 hex publish ===> Verifying dependencies... Select application(s): ------------ A) All [1-0] or (A)ll ("A")> (no clear what to enter; I tried nothing, A, "A", etc.), it just stops just after I hit Enter (no output, no error, return code is 0). If I enter 0 or 1 instead: $ rebar3 hex publish ===> Verifying dependencies... Select application(s): ------------ A) All [1-0] or (A)ll ("A")> 0 ===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump ===> When submitting a bug report, please include the output of `rebar3 report "your command"` With more details: $ DEBUG=1 rebar3 hex publish ===> Load global config file /home/MY_USER/.config/rebar3/rebar.config ===> 22.0 satisfies the requirement for MY_COMPUTERmum OTP version 18 ===> 22.0 satisfies the requirement for MY_COMPUTERmum OTP version 18 ===> Not adding provider hex user from module rebar3_hex_user because it already exists from module rebar3_hex_user ===> Not adding provider hex cut from module rebar3_hex_cut because it already exists from module rebar3_hex_cut ===> Not adding provider hex key from module rebar3_hex_key because it already exists from module rebar3_hex_key ===> Not adding provider hex owner from module rebar3_hex_owner because it already exists from module rebar3_hex_owner ===> Not adding provider hex repo from module rebar3_hex_repo because it already exists from module rebar3_hex_repo ===> Not adding provider hex docs from module rebar3_hex_docs because it already exists from module rebar3_hex_docs ===> Not adding provider hex search from module rebar3_hex_search because it already exists from module rebar3_hex_search ===> Not adding provider hex revert from module rebar3_hex_revert because it already exists from module rebar3_hex_revert ===> Not adding provider hex retire from module rebar3_hex_retire because it already exists from module rebar3_hex_retire ===> Not adding provider hex publish from module rebar3_hex_publish because it already exists from module rebar3_hex_publish ===> Expanded command sequence to be run: [] ===> Provider: {default,do} ===> Expanded command sequence to be run: [{default,app_discovery}, {default,install_deps}, {default,lock}, {hex,publish}] ===> Provider: {default,app_discovery} ===> Provider: {default,install_deps} ===> Verifying dependencies... ===> Provider: {default,lock} ===> Provider: {hex,publish} Select application(s): ------------ A) All [1-0] or (A)ll ("A")> A So: $ rebar3 report hex publish Rebar3 report version 3.11.1+build.4421.ref76935555 generated at 2019-07-19T06:40:53+00:00 ================= Please submit this along with your issue at https://github.com/erlang/rebar3/issues (and feel free to edit out private information, if any) ----------------- Task: hexpublish Entered as: hexpublish ----------------- Operating System: x86_64-unknown-linux-gnu ERTS: Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] Root Directory: /home/MY_USER/Software/Erlang/Erlang-22.0/lib/erlang Library directory: /home/MY_USER/Software/Erlang/Erlang-22.0/lib/erlang/lib ----------------- Loaded Applications: bbmustache: 1.6.1 certifi: 2.5.1 cf: 0.2.2 common_test: 1.17.3 compiler: 7.4 crypto: 4.5 cth_readable: 1.4.5 dialyzer: 4.0 edoc: 0.11 erlware_commons: 1.3.1 eunit: 2.3.7 eunit_formatters: 0.5.0 getopt: 1.0.1 hipe: 3.19 inets: 7.0.8 kernel: 6.4 providers: 1.8.1 public_key: 1.6.7 relx: 3.32.1 sasl: 3.4 snmp: 5.3 ssl_verify_fun: 1.1.5 stdlib: 3.9 syntax_tools: 2.2 tools: 3.2 ----------------- Escript path: /usr/local/bin/rebar3 Providers: app_discovery as clean compile compile cover ct cut deps dialyzer do docs edoc escriptize eunit get-deps help install install_deps key list lock new owner path pkgs publish release relup repo report repos retire revert search shell state tar tree unlock update upgrade upgrade upgrade user version xref Any help appreciated! Thanks in advance, Best regards, Olivier. PS: By the way, the 'info' command (mentioned in https://www.rebar3.org/docs/hex-package-management) does not seem to exist: $ rebar3 hex info ===> Fetching rebar3_hex v6.7.0 ===> Version cached at /home/MY_USER/.cache/rebar3/hex/hexpm/packages/rebar3_hex-6.7.0.tar is up to date, reusing it ===> Fetching hex_core v0.5.0 ===> Version cached at /home/MY_USER/.cache/rebar3/hex/hexpm/packages/hex_core-0.5.0.tar is up to date, reusing it ===> Fetching verl v1.0.1 ===> Version cached at /home/MY_USER/.cache/rebar3/hex/hexpm/packages/verl-1.0.1.tar is up to date, reusing it ===> Compiling verl ===> Compiling hex_core ===> Compiling rebar3_hex ===> Command info not found in namespace hex

Posted by Olivier Boudeville 2 months ago

2
ANSWERED

How do I include an escript in a release?

# create an escript: ```bash cd ~/temp rebar3 new escript foo cd foo rebar3 escriptize ``` And I can see the binary script here: `_build/default/bin/foo`. # create release ```bash cd ~/temp rebar3 new release bar cd bar rebar3 compile rebar3 release ``` And I can see the binary script at `_build/default/rel/bar/bin/bar`. # create release with an escript ```bash cd ~/temp rebar3 new release baz cd baz/apps rebar3 new escript bing ``` Now I add bing to the baz rebar.config: ```Erlang $ cat rebar.config {erl_opts, [debug_info]}. {deps, []}. {relx, [{release, {baz, "0.1.0"}, [baz, bing, sasl]}, {sys_config, "./config/sys.config"}, {vm_args, "./config/vm.args"}, {dev_mode, true}, {include_erts, false}, {extended_start_script, true}] }. {profiles, [{prod, [{relx, [{dev_mode, false}, {include_erts, true}]}] }] }. ``` And try and build it... ```bash $ rebar3 do compile escriptize ===> Verifying dependencies... ===> Compiling bing ===> Compiling baz ``` And take a look at the _build dir: ```bash ~/temp/baz $ find _build/ _build/ _build/default _build/default/lib _build/default/lib/baz _build/default/lib/baz/include _build/default/lib/baz/ebin _build/default/lib/baz/ebin/baz_sup.beam _build/default/lib/baz/ebin/baz.app _build/default/lib/baz/ebin/baz_app.beam _build/default/lib/baz/.rebar3 _build/default/lib/baz/.rebar3/rebar_compiler_erl _build/default/lib/baz/.rebar3/rebar_compiler_erl/source.dag _build/default/lib/baz/priv _build/default/lib/baz/src _build/default/lib/bing _build/default/lib/bing/include _build/default/lib/bing/ebin _build/default/lib/bing/ebin/bing.beam _build/default/lib/bing/ebin/bing.app _build/default/lib/bing/.rebar3 _build/default/lib/bing/.rebar3/rebar_compiler_erl _build/default/lib/bing/.rebar3/rebar_compiler_erl/source.dag _build/default/lib/bing/priv _build/default/lib/bing/src ``` Notice that there is no binary script for the escript. Ok, so I'm fishing around here... add it to the top level rebar.config deps? ```Erlang $ cat rebar.config {erl_opts, [debug_info]}. {deps, [bing]}. ... ``` Some result. What happens when we build the release? ```bash rebar3 release ===> Verifying dependencies... ===> Compiling bing ===> Compiling baz ===> Starting relx build process ... ===> Resolving OTP Applications from directories: /home/toddg/temp/rebar/baz/_build/default/lib /home/toddg/temp/rebar/baz/apps /home/toddg/.asdf/installs/erlang/22.0.3/lib ===> Resolved baz-0.1.0 ===> Dev mode enabled, release will be symlinked ===> release successfully created! ~/temp/rebar/baz $ find _build/ _build/ _build/default _build/default/rel _build/default/rel/baz _build/default/rel/baz/bin _build/default/rel/baz/bin/baz _build/default/rel/baz/bin/nodetool _build/default/rel/baz/bin/install_upgrade.escript _build/default/rel/baz/bin/baz-0.1.0 _build/default/rel/baz/bin/start_clean.boot _build/default/rel/baz/bin/no_dot_erlang.boot _build/default/rel/baz/releases _build/default/rel/baz/releases/start_erl.data _build/default/rel/baz/releases/0.1.0 _build/default/rel/baz/releases/0.1.0/baz.boot _build/default/rel/baz/releases/0.1.0/baz.rel _build/default/rel/baz/releases/0.1.0/vm.args _build/default/rel/baz/releases/0.1.0/baz.script _build/default/rel/baz/releases/0.1.0/start_clean.boot _build/default/rel/baz/releases/0.1.0/sys.config _build/default/rel/baz/releases/0.1.0/no_dot_erlang.boot _build/default/rel/baz/releases/RELEASES _build/default/rel/baz/lib _build/default/rel/baz/lib/baz-0.1.0 _build/default/rel/baz/lib/bing-0.1.0 _build/default/lib _build/default/lib/baz _build/default/lib/baz/include _build/default/lib/baz/ebin _build/default/lib/baz/ebin/baz_sup.beam _build/default/lib/baz/ebin/baz.app _build/default/lib/baz/ebin/baz_app.beam _build/default/lib/baz/.rebar3 _build/default/lib/baz/.rebar3/rebar_compiler_erl _build/default/lib/baz/.rebar3/rebar_compiler_erl/source.dag _build/default/lib/baz/priv _build/default/lib/baz/src _build/default/lib/bing _build/default/lib/bing/include _build/default/lib/bing/ebin _build/default/lib/bing/ebin/bing.beam _build/default/lib/bing/ebin/bing.app _build/default/lib/bing/.rebar3 _build/default/lib/bing/.rebar3/rebar_compiler_erl _build/default/lib/bing/.rebar3/rebar_compiler_erl/source.dag _build/default/lib/bing/priv _build/default/lib/bing/src ``` So there's still no `bing` binary script. And of course, if I invoke `rebar package` it's not there either. Why am I doing this? I'd like to deploy my erlang apps into Docker containers. However, the containers exit if the process exits, or if the process is daemonized when using `start`. I've tried starting my erlang apps with `console` but that gives weird errors and seems dirty. I saw this somewhere and I really like the idea of having a launching escript that can respond to configuration changes... this is where I'm starting: # this would be the bing escript above ```Erlang -module(launch). %% API exports -export([main/1]). %%==================================================================== %% API functions %%==================================================================== %% escript Entry point main(_) -> start_app(), loop(), erlang:halt(0). %%==================================================================== %% Internal functions %%==================================================================== loop() -> receive non_existent_message -> ok after 60000 -> % restart app if it's died start_app(), loop() end. start_app() -> case whereis(baz) of undefined -> io:format("Launching application: baz...~n", []), baz:start(); _Pid -> io:format("Application running: baz~n", []), ok end. ``` I can put metrics into the script, etc. So, back to the main question: How do I include an escript in a release?

Posted by Todd Greenwood 3 months ago