uwiger / parse_trans

Parse transform utilities for Erlang
Apache License 2.0
230 stars 118 forks source link

Cannot compile in Alpine Linux #30

Open simpers opened 6 years ago

simpers commented 6 years ago

I'm trying to setup a workflow where I can compile my app in a docker container running Alpine Linux such that the release will then run in a docker image in a Kubernetes cluster. I'm using distillery and edeliver for this.

I do however get this when trying to compile my own app, as parse_trans is a part of the dependency tree. My app is a Phoenix 1.3.2 application.

In the Alpine Linux container I have these versions of Erlang and Elixir:

Erlang:

Erlang/OTP 20 [erts-9.1.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.1.5

Elixir (might not interesting for you I suppose):

IEx 1.5.2

Error when trying to compile parse_trans

DEBUG=1 rebar3 bare compile --paths "/tmp/edeliver/tol/builds/_build/prod/lib/*/ebin"         
===> Expanded command sequence to be run: []
===> Provider: {default,do}
===> Expanded command sequence to be run: [{default,app_discovery},
                                                  {bare,compile}]
===> Provider: {default,app_discovery}
===> Provider: {bare,compile}
===> Compiling parse_trans
===> run_hooks("/tmp/edeliver/tol/builds/deps/parse_trans", pre_hooks, compile) -> no hooks defined

===> run_hooks("/tmp/edeliver/tol/builds/deps/parse_trans", pre_hooks, erlc_compile) -> no hooks defined

===> erlopts [debug_info]
===> files to compile ["/tmp/edeliver/tol/builds/deps/parse_trans/src/exprecs.erl",
                              "/tmp/edeliver/tol/builds/deps/parse_trans/src/ct_expand.erl",
                              "/tmp/edeliver/tol/builds/deps/parse_trans/src/parse_trans_pp.erl",
                              "/tmp/edeliver/tol/builds/deps/parse_trans/src/parse_trans_mod.erl",
                              "/tmp/edeliver/tol/builds/deps/parse_trans/src/parse_trans.erl",
                              "/tmp/edeliver/tol/builds/deps/parse_trans/src/parse_trans_codegen.erl"]
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: undef
===> Stack trace to the error location:
[{erl_syntax,type,[{attribute,626,module,exprecs}],[]},
 {rebar_erlc_compiler,parse_attrs,3,
                      [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_erlc_compiler.erl"},
                       {line,670}]},
 {rebar_erlc_compiler,modify_erlcinfo,5,
                      [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_erlc_compiler.erl"},
                       {line,478}]},
 {rebar_erlc_compiler,'-update_erlcinfo_fun/2-fun-0-',4,
                      [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_erlc_compiler.erl"},
                       {line,463}]},
 {lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
 {rebar_erlc_compiler,init_erlcinfo,4,
                      [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_erlc_compiler.erl"},
                       {line,411}]},
 {rebar_erlc_compiler,compile_dirs,5,
                      [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_erlc_compiler.erl"},
                       {line,195}]},
 {rebar_erlc_compiler,compile,2,
                      [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_erlc_compiler.erl"},
                       {line,121}]}]
===> When submitting a bug report, please include the output of `rebar3 report "your command"`
simpers commented 6 years ago

Actually, this might be due to rebar3 and not this project itself. I guess we should close it.

ning-y commented 6 years ago

@simpers I got the same problem on alpine:3.7. Do you have a fix for the rebar3 issue?

simpers commented 6 years ago

@ningyuansg unfortunately this is not possible on 3.7 as this package is only available in edge for now. Rebar3 Alpine Linux package

So I decided to just build my edeliver-builder against edge for now, but it might be possible to have the server-image be 3.7 after it's been built etc.

fenollp commented 6 years ago

I know this works:

docker run --rm -t erlang:alpine /bin/sh -xc 'apk update && apk upgrade && apk add git curl make && curl --fail --output /usr/local/bin/rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x /usr/local/bin/rebar3 && rebar3 --version && git clone https://github.com/uwiger/parse_trans.git && cd parse_trans && rebar3 compile'

but it uses erlang:alpine which right now is based on alpine:3.8

simpers commented 6 years ago

@fenollp So that rebar3 is working on 3.8? How is this possible? There is no rebar3 package in the 3.8 repos though, which makes me wonder why that is if there's a binary out there that works.

bhuvankrishna commented 5 years ago

I get a similar error while installing pleroma. When I run mix pleroma.instance.gen as suggested in pleroma install guide I get the same error in the crashdump of rebar3

Error: {badmatch,[]}
[{rebar_prv_bare_compile,do,1,
                         [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_prv_bare_compile.erl"},
                          {line,47}]},
 {rebar_core,do,2,
             [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_core.erl"},
              {line,154}]},
 {rebar_prv_do,do_tasks,2,
               [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_prv_do.erl"},
                {line,68}]},
 {rebar_core,do,2,
             [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_core.erl"},
              {line,154}]},
 {rebar3,main,1,
         [{file,"/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar3.erl"},
          {line,66}]},
 {escript,run,2,[{file,"escript.erl"},{line,758}]},
 {escript,start,1,[{file,"escript.erl"},{line,277}]},
 {init,start_em,1,[]}]

As sugested in another issue I think it may not be related to parse_trans but I don't know how to approch this issue and fix it. This is on debian testing with the following version or rebar3 rebar 3.6.1 on Erlang/OTP 21 Erts 10.2.4

fenollp commented 5 years ago

Can it be that you used code compiled with a different major version of OTP? A cache not evicted? I don’t know if there are garanties on the backwards compatibility of the compiled BEAM code.

bhuvankrishna commented 5 years ago

The problem was with erlang version. I installed erlang package that came with debian and not the one that is suggested by pleroma doc. After installing the deb from erlang everything worked.

z411 commented 5 years ago

@bhuvankrishna Excuse me, do you know which version of erlang caused the problem and which one fixed it? I'm using the newly released Debian 10 release (buster) and the suggested repos don't have a repo for it yet, so I'll probably need to build the packages myself.

EDIT: I tried using erlang packages from sid (version 22.0) but they don't work either. I wonder if there's something wrong with the Debian packages?

bhuvankrishna commented 5 years ago

@bhuvankrishna Excuse me, do you know which version of erlang caused the problem and which one fixed it? I'm using the newly released Debian 10 release (buster) and the suggested repos don't have a repo for it yet, so I'll probably need to build the packages myself.

EDIT: I tried using erlang packages from sid (version 22.0) but they don't work either. I wonder if there's something wrong with the Debian packages?

@z411 erlang version provided by debian is not working. I added repository from erlang download page. In fact the process is to download the deb and install it with dpkg -i package

neysofu commented 4 years ago

The following solved this for me:

apk add --update alpine-sdk