ninenines / erlang.mk

A build tool for Erlang that just works.
https://erlang.mk
ISC License
578 stars 241 forks source link

Release fails to build if top folder name is different from app name #964

Closed pankajsoni19 closed 1 year ago

pankajsoni19 commented 1 year ago

make[1]: Leaving directory '/codebuild/output/src236792627/src/deps/base64url'
--
1006 | DEPEND scheduler.d
1007 | ERLC   gen_mod.erl mod_listener.erl mod_rest_handler.erl mod_account.erl mod_alive.erl mod_cluster.erl mod_config.erl mod_monitor.erl mod_nats.erl mod_redis.erl mod_redis_pool.erl mod_scheduler.erl mod_scheduler_db.erl mod_scheduler_rest.erl mod_session.erl mod_sql.erl mod_time.erl mod_utils.erl scheduler_app.erl scheduler_sup.erl
1008 | APP    scheduler
1009 | erl +A1 -noinput -boot no_dot_erlang -pa ebin/ -pz /codebuild/output/src236792627/src/.erlang.mk/rebar/ebin -eval " {ok, Config} = file:consult(\"/codebuild/output/src236792627/src/relx.config\"),    {release, {Name, Vsn0}, _} = lists:keyfind(release, 1, Config), Vsn = case Vsn0 of      {cmd, Cmd} -> os:cmd(Cmd);      semver -> \"\";     {semver, _} -> \"\";        VsnStr -> Vsn0  end,    {ok, _} = relx:build_release(#{name => Name, vsn => Vsn}, Config),  halt(0)." -- erlang.mk
1010 | Solving Release server-1.0.0{"init terminating in do_boot",{{error,{rlx_resolve,{app_not_found,scheduler,undefined}}},[{rlx_resolve,subset,7,[{file,"src/rlx_resolve.erl"},{line,72}]},{rlx_resolve,'-fold_apps/7-fun-0-',7,[{file,"src/rlx_resolve.erl"},{line,99}]},{lists,foldl,3,[{file,"lists.erl"},{line,1350}]},{rlx_resolve,subset,5,[{file,"src/rlx_resolve.erl"},{line,54}]},{rlx_resolve,solve_release,2,[{file,"src/rlx_resolve.erl"},{line,48}]},{relx,build_release_,3,[{file,"src/relx.erl"},{line,170}]},{relx,build_release,3,[{file,"src/relx.erl"},{line,87}]},{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,744}]}]}}
1011 | init terminating in do_boot ({{error,{rlx_resolve,{app_not_found,scheduler,undefined}}},[{rlx_resolve,subset,7,[{_},{_}]},{rlx_resolve,-fold_apps/7-fun-0-,7,[{_},{_}]},{lists,foldl,3,[{_},{_}]},{rlx_resolve,subset,5,[{_},{_}]},{rlx_resolve,solve_release,2,[{_},{_}]},{relx,build_release_,3,[{_},{_}]},{relx,build_release,3,[{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]}]})
1012 |  
1013 | Crash dump is being written to: erl_crash.dump...done
1014 | erlang.mk:7539: recipe for target 'relx-rel' failed
1015 | make: *** [relx-rel] Error 1
1016 |  
1017 | [Container] 2022/11/10 09:03:11 Command did not exit successfully make clean deps app rel exit status 2
1018 | [Container] 2022/11/10 09:03:11 Phase complete: BUILD State: FAILED
1019 | [Container] 2022/11/10 09:03:11 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: make clean deps app rel. Reason: exit status 2

This is using latest erlang.mk build on AWS docker, using ubuntu 18.04 image

pankajsoni19 commented 1 year ago

structure

scheduler/src/*.erl
scheduler/deps
scheduler/include

scheduler/src/server_sup.erl
scheduler/src/server_app.erl

below works. ebin/server.app is generated correctly.

make app

make rel breaks with error

erl +A1 -noinput -boot no_dot_erlang -pa ebin/ -pz /Users/pankajsoni/Documents/myyogateacher/repos/scheduler/.erlang.mk/rebar/ebin -eval " {ok, Config} = file:consult(\"/Users/pankajsoni/Documents/myyogateacher/repos/scheduler/relx.config\"),  {release, {Name, Vsn0}, _} = lists:keyfind(release, 1, Config),     Vsn = case Vsn0 of              {cmd, Cmd} -> os:cmd(Cmd);              semver -> \"\";         {semver, _} -> \"\";                VsnStr -> Vsn0  end,    {ok, _} = relx:build_release(#{name => Name, vsn => Vsn}, Config),      halt(0)." -- erlang.mk
Solving Release server-1.0.0{"init terminating in do_boot",{{error,{rlx_resolve,{app_not_found,server,undefined}}},[{rlx_resolve,subset,7,[{file,"src/rlx_resolve.erl"},{line,72}]},{rlx_resolve,'-fold_apps/7-fun-0-',7,[{file,"src/rlx_resolve.erl"},{line,99}]},{lists,foldl,3,[{file,"lists.erl"},{line,1350}]},{rlx_resolve,subset,5,[{file,"src/rlx_resolve.erl"},{line,54}]},{rlx_resolve,solve_release,2,[{file,"src/rlx_resolve.erl"},{line,48}]},{relx,build_release_,3,[{file,"src/relx.erl"},{line,170}]},{relx,build_release,3,[{file,"src/relx.erl"},{line,87}]},{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,744}]}]}}
init terminating in do_boot ({{error,{rlx_resolve,{app_not_found,server,undefined}}},[{rlx_resolve,subset,7,[{_},{_}]},{rlx_resolve,-fold_apps/7-fun-0-,7,[{_},{_}]},{lists,foldl,3,[{_},{_}]},{rlx_resolve,subset,5,[{_},{_}]},{rlx_resolve,solve_release,2,[{_},{_}]},{relx,build_release_,3,[{_},{_}]},{relx,build_release,3,[{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]}]})

makefile

PROJECT = server

PROJECT_VERSION = $(shell head -n 1 relx.config | awk '{split($$0, a, "\""); print a[2]}')

# app:: rebar.config

COMPILE_FIRST = gen_mod

LOCAL_DEPS = inets mnesia os_mon
DEPS = lager lager_json p1_utils uuid cowboy erlpool jsx mysql_poolboy erlcloud eredis teacup_nats nats_msg base64url

dep_lager = git https://github.com/erlang-lager/lager.git 3.9.2
dep_lager_json = git https://github.com/pankajsoni19/lager-json 1.0.1
dep_p1_utils = git https://github.com/processone/p1_utils.git 1.0.25
dep_uuid = git https://github.com/okeuday/uuid.git v2.0.5
dep_cowboy = git https://github.com/ninenines/cowboy.git 2.9.0
dep_erlpool = git https://github.com/pankajsoni19/erlpool.git v1.4
dep_jsx = git https://github.com/talentdeficit/jsx.git v3.1.0
dep_mysql_poolboy = git https://github.com/mysql-otp/mysql-otp-poolboy.git 0.2.1
dep_erlcloud = git https://github.com/erlcloud/erlcloud.git 3.6.5
dep_eredis = git https://github.com/pankajsoni19/eredis.git v1.3.0
dep_teacup_nats = git https://github.com/yuce/teacup_nats.git 0.4.1
dep_nats_msg = hex 0.4.1
dep_base64url = git https://github.com/dvv/base64url.git 1.0.1

BUILD_DEPS += relx
include erlang.mk

ERLC_OPTS := $(filter-out -Werror,$(ERLC_OPTS))

ERLC_COMPILE_OPTS= +'{parse_transform, lager_transform}'
ERLC_OPTS += $(ERLC_COMPILE_OPTS)
TEST_ERLC_OPTS += $(ERLC_COMPILE_OPTS)

relx.config

{release, {server, "1.0.0"}, [server, sasl, runtime_tools]}.
{dev_mode, false}.
{include_erts, true}.
{include_src, false}.
{extended_start_script, true}.
{sys_config, "config/sys.config"}.
{vm_args, "config/vm.args"}.
essen commented 1 year ago

That's just how Erlang/OTP works. The application name must match the directory name. Not much I can do about that.

pankajsoni19 commented 1 year ago

aws code build creates code under temporary directory. its difficult to rename that.

ex

make[1]: Leaving directory '/codebuild/output/src236792627/src/deps/base64url'

what would you suggest in that case?

essen commented 1 year ago

You can use multi-application layout so your application would be under apps/.