[erlang-questions] Escript archives and the load path

Siri Hansen erlangsiri@REDACTED
Wed Jul 11 10:35:05 CEST 2012


Hi Geoff!

There is no good way to do this really. Since rebar is an escript, the code
server can not read it as a general archive. The only option you have would
be to extract the archive part from it, write it to a file with .ez
extension and then add code path to it, e.g.

1> {ok,Stuff} = escript:extract("rebar",[]).
{ok,[{shebang,default},
     {comment,[]},
     {emu_args,"-noshell -noinput"},
     {archive,<<80,75,3,4,20,0,0,0,8,0,15,84,235,64,105,178,
                62,157,168,18,0,...>>}]}
2>
2> Bin = proplists:get_value(archive,Stuff).
<<80,75,3,4,20,0,0,0,8,0,15,84,235,64,105,178,62,157,168,
  18,0,0,164,30,0,0,11,0,0,...>>
3> file:write_file("rebar.ez",Bin).
ok
4> erl_prim_loader:list_dir("rebar.ez").
{ok,["priv","rebar_xref.beam","rebar_utils.beam",
     "rebar_upgrade.beam","rebar_templater.beam",
     "rebar_subdirs.beam","rebar_require_vsn.beam",
     "rebar_reltool.beam","rebar_rel_utils.beam",
     "rebar_protobuffs_compiler.beam","rebar_port_compiler.beam",
     "rebar_otp_app.beam","rebar_neotoma_compiler.beam",
     "rebar_log.beam","rebar_lfe_compiler.beam",
     "rebar_file_utils.beam","rebar_eunit.beam",
     "rebar_escripter.beam","rebar_erlydtl_compiler.beam",
     "rebar_erlc_compiler.beam","rebar_edoc.beam",
     "rebar_deps.beam","rebar_ct.beam","rebar_core.beam",
     "rebar_config.beam","rebar_cleaner.beam",
     [...]|...]}
5> code:which(rebar).
non_existing
6> code:add_path("rebar.ez").
true
7> code:which(rebar).
"rebar.ez/rebar.beam"
8>


Regards
/siri

2012/7/10 Geoff Cant <nem@REDACTED>

>
> Hi all, after looking for a while, I couldn't figure out how to tell
> ERTS or the code server that /some/path/rebar was a valid place to load
> modules from.
>
> Is there a magic function / command-line flag I can use to get the
> contents of this escript archive into the code path?
>
> Cheers,
> --
> Geoff Cant
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120711/924cac2e/attachment.htm>


More information about the erlang-questions mailing list