-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
escriptize failing with elixir dependencies in rebar3_elixir_compile (find_deps_of_deps) #1568
Comments
Hrm. This is a tricky one, and since I don't use Elixir (don't have it installed) this is tricky to debug. My guess is that this happens because the dependency is declared in the .app file generated for it, but the One thing to try would be to add the elixir plugin's compile hooks as a pre-hook to escriptize, or to at least run the compile job once before building the escript. This is not guaranteed to work since hooks cannot inject state into their related apps, but it's worth a try since it could make things be in the right paths to be discovered. If it doesn't work, then the elixir plugin may have to provide its own functionality that can encompass both. I don't know that we can easily or reasonably make an escriptize version that does not trust its own compile dependency and re-runs a discovery for third-party plugin usage. |
I have an issue in the The solution in rebar2 was to invoke {post_hooks, [{compile, "${MAKE:-make} escriptize"}]}. For rebar3 (checked in case erlang:function_exported(rebar3, main, 1)
true ->
lists:keydelete(post_hooks, 1, CONFIG1)
++ [{provider_hooks, [{post, [{compile, escriptize}]}]}];
_ ->
CONFIG1
end. While this works for Thus: IsRebar3Bare = (nomatch =/= re:run(init:get_plain_arguments(), "rebar3bare")).
...
%% It seems `rebar3 bare compile` (mix) fails if the following subst is made.
case erlang:function_exported(rebar3, main, 1) andalso (not IsRebar3Bare) of
true ->
lists:keydelete(post_hooks, 1, CONFIG1)
++ [{provider_hooks, [{post, [{compile, escriptize}]}]}];
_ ->
CONFIG1
end. Hardly a generic, or particularly satisfactory, solution, but perhaps it can inspire something better? |
Aaah, this is because mix runs bare compile at the root of the setup
project, resulting in project plugins being run. We could have in a env
var for mix to set to turn them off I guess...
--
Tristan Sloughter
"I am not a crackpot" - Abe Simpson
tristan.sloughter@gmail.com
On Fri, Sep 15, 2017, at 03:49 AM, Ulf Wiger wrote:
I have an issue in the setup repos related to this, and think I've
found a perverse workaround.> uwiger/setup#41[1]
The solution in rebar2 was to invoke make escriptize in the
post_hooks.> {post_hooks, [{compile, "${MAKE:-make} escriptize"}]}.
For rebar3 (checked in rebar.config.script), we remove that post_hook
and insert a provider_hooks entry.> case erlang:function_exported(rebar3, main, 1) true ->
lists:keydelete(post_hooks, 1, CONFIG1) ++ [{provider_hooks, [{post,
[{compile, escriptize}]}]}]; _ -> CONFIG1 end.> While this works for rebar3, it doesn't seem to work when mix invokes
rebar3 bare compile. Checking for this and leaving the rebar2 solution
in place seems to work. This means that the make command will actually
use rebar2 for the escriptize operation (perhaps not necessary, but
that's how it works in the current Makefile.)> Thus:
IsRebar3Bare = (nomatch =/= re:run(init:get_plain_arguments(),
"rebar3bare")). ...
%% It seems `rebar3 bare compile` (mix) fails if the following subst
%% is made.
case erlang:function_exported(rebar3, main, 1) andalso (not
IsRebar3Bare) of true -> lists:keydelete(post_hooks, 1, CONFIG1)
++ [{provider_hooks, [{post, [{compile, escriptize}]}]}]; _ ->
CONFIG1 end.> Hardly a generic, or particularly satisfactory, solution, but perhaps
it can inspire something better?> — You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub[2], or mute the
thread[3].>
|
Argh, I completely mis read this in my morning haze and now when rereading it I realize what I said was completely unrelated. It still may be an issue with mix and project plugins but it is not related to what is going on here. |
I have a similar issue compile a project that contains cuttlefish.
It's an elixir project and the problem is related to |
I think I have some idea of what is going on here, as I just ran into this with In my case, I hit the same stack trace in
Based on what rebar3 is doing when it fails (looking up an application in a list of applications), the only thing that could possibly be different is if the way it's looking up applications is affected by /cc @ericmj |
When building the cuttlefish library as a dependency through `mix`, the build fails when attempting to run the `escriptize` hook. Comment the hook out to make building with `mix` work. The problem has been mentioned on the [Elixir forum][1], and technical discussion can be found [on Github][2]. [1]: https://elixirforum.com/t/erlang-dependency-doesnt-compile-with-mix/7043 [2]: erlang/rebar3#1568
Solution, in
|
The way to use elixir deps is with https://github.com/Supersonido/rebar_mix these days so I'm consdiering closing this and requiring it be reopened if there is still an issue when using the new plugin. |
💯 agreed! |
Without commenting the line, it would fail to compile when compiling as a dep in mix.exs. erlang/rebar3#1568
I want to run an escript with elixir dependencies (well, basically I just wanna run a script in erlang with elixir dependencies and figured escript would be the way to go). Repo is here: https://github.com/PragTob/benchee_erlang_try (calling the elixir code from an eshell ession works)
Worth noting that I already filed an issue with the rebar3 plugin for using elixir dependencies but haven't received an answer yet and am also not sure what/where it goes wrong barrel-db/rebar3_elixir_compile#21
Thanks a lot in advance :)
Environment
Current behaviour
Escriptizing fails around here somewhat similar to #1560 as in the compiled things might be in
_elixir_build
and not_build
although I see the dependencies in _build as well.Error occurs during escriptizing.
Expected behaviour
I would like my escript to be build so that I can run benchee benchmarks from erlang in a compiled escript seamlessly :) Any help is gladly welcome, granted, I'm not much of an Erlang/rebar3 specialist :)
Thanks for all the great work 🚀
The text was updated successfully, but these errors were encountered: