[erlang-questions] Multiple application configurations in multiple files

Attila Rajmund Nohl attila.r.nohl@REDACTED
Wed Mar 29 11:55:21 CEST 2017


Hello!

I'm looking into the following corner case: what if the Erlang VM is
started with multiple configuration files, at least one of the
containing multiple configurations for the same application? For
example I have these two configuration files:

3.config:
[
 {sasl, [
         {key, value3},
         {key3, value3}
        ]},
 {sasl, [
         {key, value3},
         {key3, value3}
        ]}
].

4.config:
[
 {sasl, [
         {key, value4},
         {key4, value4}
        ]}
].

I can start erlang with this command, load the sasl application and
check the environment:
erl -config 3 -config 4
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:2:2]
[async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.3  (abort with ^G)
1> application:load(sasl).
ok
2> application:get_all_env(sasl).
[{key,value3},
 {key3,value3},
 {sasl_error_logger,tty},
 {included_applications,[]},
 {errlog_type,all}]

Based on the comments in application_controller.erl ("Env2 overrides
Env1"), I expected to get {key, value3}, {key3, value3} and {key4,
value4} in the environment, not {key, value3} and {key3, value3}.
Interestingly, when there's only one sasl configuration in 3.config, I
do get the merged environment:
2> application:get_all_env(sasl).
[{key,value4},
 {key3,value3},
 {sasl_error_logger,tty},
 {key4,value4},
 {included_applications,[]},
 {errlog_type,all}]

Is it a bug or a feature that if there's multiple configuration for
the same application in a config file, only the last one is used?



More information about the erlang-questions mailing list