erlang / rebar3

Erlang build tool that makes it easy to compile and test Erlang applications and releases.
http://www.rebar3.org
Apache License 2.0
1.69k stars 515 forks source link

[Question] How to make a "escript" file to a binary executable? #2366

Closed amadeu01 closed 4 years ago

amadeu01 commented 4 years ago

I found those threads about making an escript file an executable:

http://erlang.org/pipermail/erlang-questions/2010-June/052046.html http://erlang.org/pipermail/erlang-questions/2010-June/052047.html

I know that those threads are about the old version of the rebar, but I would like to know how I should proceed by using the rebar3

Here I quote them:

Hi Bernard,

Chris pointed out a way to do it in "rebar". And it really works: http://hg.basho.com/rebar/src/tip/src/rebar_escripter.erl

Regards Zabrane

Unfortunately, it does not provide more detail and the link is broken. So, I'm not sure how I should proceed to make the executable not depending on the erlang installed the user's machine. Just to be clear, what I would like to achieve is to make an binary executable that I will be able to run on machines regardless it having or not the erlang/beam system previously installed on it. Is it possible? If, so how can I do? I'm currently using elixir to build the escript (mix escript.build), then making the command line that I want to execute in others computers that does not have erlang and elixir installed.

pablocostass commented 4 years ago

Hey there @amadeu01,

Unfortunately, it does not provide more detail and the link is broken.

The broken link pointed to the old rebar source code, which you can still find at https://github.com/rebar/rebar/blob/master/src/rebar_escripter.erl

At no point does that code make a binary executable, it at most made the escript itself executable.

So, I'm not sure how I should proceed to make the executable not depending on the erlang installed the user's machine. Just to be clear, what I would like to achieve is to make an binary executable that I will be able to run on machines regardless it having or not the erlang/beam system previously installed on it. Is it possible? If, so how can I do?

Sadly escripts depend on Erlang being installed in the other machines you are planning to use, so with your current constraints I think it is not possible. There is an old issue where @ferd explained it better (https://github.com/erlang/rebar3/issues/1800#issuecomment-393865390). However, a few things come to my mind:

I'm currently using elixir to build the escript (mix escript.build), then making the command line that I want to execute in others computers that does not have erlang and elixir installed.

AFAIK Elixir bundles itself when building escripts. You still need, however, to have Erlang installed on those machines as per Elixir documentation.

ferd commented 4 years ago

Nothing to add there, this is all correct.

I'll close the issue as the main question has been answered. If @amadeu01 has follow-up questions, feel free to keep asking them in here and optionally to reopen it, we'll keep an eye on the thread regardless.

tsloughter commented 4 years ago

Since bakeware is mix only I'll link to my old gist using makeself to do similar https://gist.github.com/tsloughter/d62aad6d67b263e69275376b1c80320d

pablocostass commented 4 years ago

Since bakeware is mix only I'll link to my old gist using makeself to do similar https://gist.github.com/tsloughter/d62aad6d67b263e69275376b1c80320d

Didn't know of makeself, noted. Thank you! :)