erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
696 stars 231 forks source link

Proper way of specifying dependencies when using Relx #149

Closed ptmoy2 closed 10 years ago

ptmoy2 commented 10 years ago

I am trying to use Relx to make a release for an application that uses Yaws in embedded mode. I do not specify Yaws as a dependency in my application's .app file. I do include location of the Yaws ebin directory in my .erlang file. With this configuration, my application runs fine when started manually using application:start(myApp).

I built a Relx release using the following relx.config file:

{release, {ui, "1.0"},[ui]}. {sys_config, "../sys.config"}. {vm_args, "./vm.args"}. {output_dir, "_ui"}.

The built went fine but the release crashes when run because Erlang can't find the Yaws modules. So I changed the relx.config to this:

{release, {ui, "1.0"},[ui, yaws]}. {sys_config, "../sys.config"}. {vm_args, "./vm.args"}. {output_dir, "_ui"}. {lib_dirs, ["/home/pm/ProgramFiles/yaws-1.98"]}. {paths, ["/home/pm/ProgramFiles/yaws-1.98/ebin"]}.

When I ran Relx, built failed with error shown below:

pm@T110:~/Projects/Backtester/lib/ui$ relx release ===> Starting relx build process ... ===> Resolving OTP Applications from directories: /home/pm/ProgramFiles/yaws-1.98 /home/pm/Projects/Backtester/lib/ui/ebin /usr/lib/erlang/lib /home/pm/Projects/Backtester/lib/ui/_ui ===> Resolving available OTP Releases from directories: /home/pm/ProgramFiles/yaws-1.98 /home/pm/Projects/Backtester/lib/ui/ebin /usr/lib/erlang/lib /home/pm/Projects/Backtester/lib/ui/_ui ===> Resolved ui-1.0 escript: exception error: no function clause matching systools_make:'-format_error/1-fun-1-'({{yaws_ls,ui, "/home/pm/Projects/Backtester/lib/ui/_ui/lib/ui-0/ebin"}, {yaws_ls,yaws, "/home/pm/Projects/Backtester/lib/ui/_ui/lib/yaws-1.98/ebin"}}) (systools_make.erl, line 2221) in function lists:map/2 (lists.erl, line 1224) in call from systools_make:format_error/1 (systools_make.erl, line 2221) in call from rlx_prv_assembler:format_error/1 (src/rlx_prv_assembler.erl, line 111) in call from relx:format_error/1 (src/relx.erl, line 222) in call from relx:report_error/2 (src/relx.erl, line 303) in call from relx:handle_output/3 (src/relx.erl, line 254) in call from relx:main/1 (src/relx.erl, line 60)

Basically, I want Relx to pull in the Yaws code, but not start the Yaws application. I believe starting the Yaws application will result in a stand-alone web server, which is not what I want. I don't specify Yaws as a dependency in my .app file for this reason.

What's the recommended way of handling this in Relx? Adding lib_dirs and paths in relx.config doesn't seem to have any effect.

ptmoy2 commented 10 years ago

If I interpret the Relx documentations and examples correctly, my relx.config should be as shown below:

{release, {ui, "1.0"},[ui]}. {sys_config, "../sys.config"}. {vm_args, "./vm.args"}. {output_dir, "_ui"}. {paths, ["/home/pm/ProgramFiles/yaws-1.98/ebin"]}.

Except Relx doesn't pull in the Yaws files as it should.

I closed the issue by accident, so reopened.

ptmoy2 commented 10 years ago

On 04/01/2014 05:06 AM, Adam Lindberg wrote:

You should make your release include Yaws directly:

{release, {ui, "1.0"}, [ui, yaws]}.

— Reply to this email directly or view it on GitHub https://github.com/erlware/relx/issues/149#issuecomment-39184393.

Steve,

I did include yaws in the release, and now also specify yaws as an included application via the tuple {included_applications, [yaws]} in my application's '.app' file. But I'm still missing some of these transitory dependencies; only yaws itself got pulled in. I noticed the yaws.app file only specified 'kernel' and 'stdlib' as dependencies, so there's no way for the release handler (relx in my case) to know what additional apps to pull in unless I specify them explicitly in the relx.config file, which is what I did to get 'compiler'. Should these dependencies be included in an 'included_applications' tuple in the yaws.app file?

BTW, Is missing dependency also the cause of error shown below?

=ERROR REPORT==== 1-Apr-2014::00:00:51 === * Generic server yaws_session_server terminating * Last message in was {new_session,{session,"dd",<0.139.0>}, 2400,<0.139.0>,undefined} * When Server state == {state,yaws_session_server} * Reason for termination == \ {'module could not be loaded', [{crypto,rand_bytes,[16],[]}, {yaws_session_server,handle_call,3, [{file,"yaws_session_server.erl"},{line,154}]}, {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,585}]}, {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}

nuex commented 10 years ago

It looks like crypto is another dependency not included in the yaws .app file.

Maybe you could add all dependencies to the app file as you find them and open a PR to the Yaws project to include them?

eproxus commented 10 years ago

Yes, this is a bug in Yaws if they actually depend on these libraries. As a work around, you can manually add them to your relx.config file (maybe with a comment so it is clear why they're manually specified there).

I would suggest opening a bug report for Yaws with this information (list all dependencies you've discovered are missing).

jwilberding commented 10 years ago

Yeah, Claes Wikstrom is a good guy and fairly responsive, if you submit a PR, I am sure he will be glad to have it.

/cc @klacke

jwilberding commented 10 years ago

@ptmoy2 if you are ok now would you mind closing this?

ptmoy2 commented 10 years ago

Steve Vinoski took care of this.