diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar.hrl | 1 | ||||
-rw-r--r-- | src/rebar3.erl | 10 | ||||
-rw-r--r-- | src/rebar_app_utils.erl | 7 | ||||
-rw-r--r-- | src/rebar_config.erl | 18 | ||||
-rw-r--r-- | src/rebar_file_utils.erl | 15 | ||||
-rw-r--r-- | src/rebar_git_resource.erl | 13 | ||||
-rw-r--r-- | src/rebar_hooks.erl | 28 | ||||
-rw-r--r-- | src/rebar_log.erl | 12 | ||||
-rw-r--r-- | src/rebar_prv_common_test.erl | 25 | ||||
-rw-r--r-- | src/rebar_prv_cover.erl | 24 | ||||
-rw-r--r-- | src/rebar_prv_path.erl | 8 | ||||
-rw-r--r-- | src/rebar_prv_shell.erl | 34 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 12 | ||||
-rw-r--r-- | src/rebar_prv_upgrade.erl | 24 | ||||
-rw-r--r-- | src/rebar_state.erl | 3 | ||||
-rw-r--r-- | src/rebar_utils.erl | 20 |
16 files changed, 174 insertions, 80 deletions
diff --git a/src/rebar.hrl b/src/rebar.hrl index 0b7f0b1..4d69c7b 100644 --- a/src/rebar.hrl +++ b/src/rebar.hrl @@ -10,6 +10,7 @@ -define(INFO(Str, Args), rebar_log:log(info, Str, Args)). -define(WARN(Str, Args), rebar_log:log(warn, Str, Args)). -define(ERROR(Str, Args), rebar_log:log(error, Str, Args)). +-define(CRASHDUMP(Str, Args), rebar_log:crashdump(Str, Args)). -define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))). diff --git a/src/rebar3.erl b/src/rebar3.erl index ff0ab6a..82b4472 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -272,20 +272,22 @@ handle_error({error, rebar_abort}) -> handle_error({error, {Module, Reason}}) -> case code:which(Module) of non_existing -> - ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []), + ?CRASHDUMP("~p: ~p~n~p~n~n", [Module, Reason, erlang:get_stacktrace()]), + ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to stacktrace or consult rebar3.crashdump", []), ?DEBUG("Uncaught error: ~p ~p", [Module, Reason]), ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []); _ -> - ?ERROR(Module:format_error(Reason), []) + ?ERROR("~s", [Module:format_error(Reason)]) end, erlang:halt(1); handle_error({error, Error}) when is_list(Error) -> - ?ERROR(Error, []), + ?ERROR("~s", [Error]), erlang:halt(1); handle_error(Error) -> %% Nothing should percolate up from rebar_core; %% Dump this error to console - ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []), + ?CRASHDUMP("Error: ~p~n~p~n~n", [Error, erlang:get_stacktrace()]), + ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump", []), ?DEBUG("Uncaught error: ~p", [Error]), case erlang:get_stacktrace() of [] -> ok; diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index d3ef841..957526e 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -134,7 +134,12 @@ parse_dep(Parent, {Name, Source}, DepsDir, IsLock, State) when is_tuple(Source) dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); parse_dep(Parent, {Name, _Vsn, Source}, DepsDir, IsLock, State) when is_tuple(Source) -> dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); -parse_dep(Parent, {Name, _Vsn, Source, Opts}, DepsDir, IsLock, State) when is_tuple(Source) -> +parse_dep(Parent, {Name, _Vsn, Source, Opts}, DepsDir, IsLock, State) when is_tuple(Source), + is_list(Opts) -> + ?WARN("Dependency option list ~p in ~p is not supported and will be ignored", [Opts, Name]), + dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); +parse_dep(Parent, {Name, Source, Opts}, DepsDir, IsLock, State) when is_tuple(Source), + is_list(Opts) -> ?WARN("Dependency option list ~p in ~p is not supported and will be ignored", [Opts, Name]), dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); parse_dep(Parent, {Name, {pkg, PkgName, Vsn}, Level}, DepsDir, IsLock, State) when is_integer(Level) -> diff --git a/src/rebar_config.erl b/src/rebar_config.erl index 8d7bcf4..836980e 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -180,6 +180,24 @@ check_newly_added({Name, _, Source}, LockedDeps) -> check_newly_added(Dep, LockedDeps) -> check_newly_added_(Dep, LockedDeps). +%% get [raw] deps out of the way +check_newly_added_({Name, Source, Opts}, LockedDeps) when is_tuple(Source), + is_list(Opts) -> + case check_newly_added_(Name, LockedDeps) of + {true, Name1} -> + {true, {Name1, Source}}; + false -> + false + end; +check_newly_added_({Name,_Vsn,Source,Opts}, LockedDeps) when is_tuple(Source), + is_list(Opts) -> + case check_newly_added_(Name, LockedDeps) of + {true, Name1} -> + {true, {Name1, Source}}; + false -> + false + end; +%% and on to regular deps check_newly_added_({Name, Vsn, Source}, LockedDeps) -> case check_newly_added_(Name, LockedDeps) of {true, Name1} -> diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index 19cc94d..667be62 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -27,6 +27,7 @@ -module(rebar_file_utils). -export([try_consult/1, + consult_config/2, format_error/1, symlink_or_copy/2, rm_rf/1, @@ -63,6 +64,20 @@ try_consult(File) -> throw(?PRV_ERROR({bad_term_file, File, Reason})) end. +-spec consult_config(rebar_state:t(), string()) -> [[tuple()]]. +consult_config(State, Filename) -> + Fullpath = filename:join(rebar_dir:root_dir(State), Filename), + ?DEBUG("Loading configuration from ~p", [Fullpath]), + Config = case try_consult(Fullpath) of + [T] -> T; + [] -> [] + end, + SubConfigs = [consult_config(State, Entry ++ ".config") || + Entry <- Config, is_list(Entry) + ], + + [Config | lists:merge(SubConfigs)]. + format_error({bad_term_file, AppFile, Reason}) -> io_lib:format("Error reading file ~s: ~s", [AppFile, file:format_error(Reason)]). diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index 5a6a5ef..f0f5f03 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -17,10 +17,17 @@ lock(AppDir, {git, Url, _}) -> lock(AppDir, {git, Url}); lock(AppDir, {git, Url}) -> - AbortMsg = io_lib:format("Locking of git dependency failed in ~s", [AppDir]), + AbortMsg = lists:flatten(io_lib:format("Locking of git dependency failed in ~s", [AppDir])), + Dir = rebar_utils:escape_double_quotes(AppDir), {ok, VsnString} = - rebar_utils:sh("git --git-dir=\"" ++ rebar_utils:escape_double_quotes(AppDir) ++ "/.git\" rev-parse --verify HEAD", - [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]), + case os:type() of + {win32, _} -> + rebar_utils:sh("git rev-parse --git-dir=\"" ++ Dir ++ "/.git\" --work-tree=\"" ++ Dir ++ "\" --verify HEAD", + [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]); + _ -> + rebar_utils:sh("git --git-dir=\"" ++ Dir ++ "/.git\" rev-parse --verify HEAD", + [{use_stdout, false}, {debug_abort_on_error, AbortMsg}]) + end, Ref = string:strip(VsnString, both, $\n), {git, Url, {ref, Ref}}. diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl index 3af17ca..d6a0e2b 100644 --- a/src/rebar_hooks.erl +++ b/src/rebar_hooks.erl @@ -38,18 +38,22 @@ run_provider_hooks(Dir, Type, Command, Providers, Opts, State) -> run_provider_hooks_(_Dir, _Type, _Command, _Providers, [], State) -> State; run_provider_hooks_(Dir, Type, Command, Providers, TypeHooks, State) -> - PluginDepsPaths = rebar_state:code_paths(State, all_plugin_deps), - code:add_pathsa(PluginDepsPaths), - Providers1 = rebar_state:providers(State), - State1 = rebar_state:providers(rebar_state:dir(State, Dir), Providers++Providers1), - HookProviders = proplists:get_all_values(Command, TypeHooks), - case rebar_core:do(HookProviders, State1) of - {error, ProviderName} -> - ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []), - throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName})); - {ok, State2} -> - rebar_utils:remove_from_code_path(PluginDepsPaths), - State2 + case proplists:get_all_values(Command, TypeHooks) of + [] -> + State; + HookProviders -> + PluginDepsPaths = lists:usort(rebar_state:code_paths(State, all_plugin_deps)), + code:add_pathsa(PluginDepsPaths), + Providers1 = rebar_state:providers(State), + State1 = rebar_state:providers(rebar_state:dir(State, Dir), Providers++Providers1), + case rebar_core:do(HookProviders, State1) of + {error, ProviderName} -> + ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []), + throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName})); + {ok, State2} -> + rebar_utils:remove_from_code_path(PluginDepsPaths), + State2 + end end. format_error({bad_provider, Type, Command, {Name, Namespace}}) -> diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 23ae81e..b1a70c2 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -27,6 +27,7 @@ -module(rebar_log). -export([init/2, + crashdump/2, set_level/1, get_level/0, error_level/0, @@ -73,6 +74,7 @@ init(Caller, Verbosity) -> ?DEBUG_LEVEL -> debug end, Intensity = intensity(), + application:set_env(rebar, log_caller, Caller), Log = ec_cmd_log:new(Level, Caller, Intensity), set_level(valid_level(Verbosity)), application:set_env(rebar, log, Log). @@ -95,6 +97,16 @@ log(Level, Str, Args) -> {ok, LogState} = application:get_env(rebar, log), ec_cmd_log:Level(LogState, Str++"~n", Args). +crashdump(Str, Args) -> + crashdump("rebar3.crashdump", Str, Args). +crashdump(File, Str, Args) -> + case application:get_env(rebar, log_caller) of + {ok, api} -> + ok; + _ -> + file:write_file(File, io_lib:fwrite(Str, Args)) + end. + error_level() -> ?ERROR_LEVEL. default_level() -> ?INFO_LEVEL. diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl index 5712fbf..fbd0e89 100644 --- a/src/rebar_prv_common_test.erl +++ b/src/rebar_prv_common_test.erl @@ -116,6 +116,7 @@ prepare_tests(State) -> %% rebar.config test options CfgOpts = cfgopts(State), ProjectApps = rebar_state:project_apps(State), + %% prioritize tests to run first trying any command line specified %% tests falling back to tests specified in the config file finally %% running a default set if no other tests are present @@ -215,6 +216,14 @@ add_hooks(Opts, State) -> select_tests(_, _, {error, _} = Error, _) -> Error; select_tests(_, _, _, {error, _} = Error) -> Error; select_tests(State, ProjectApps, CmdOpts, CfgOpts) -> + %% set application env if sys_config argument is provided + SysConfigs = sys_config_list(CmdOpts, CfgOpts), + Configs = lists:flatmap(fun(Filename) -> + rebar_file_utils:consult_config(State, Filename) + end, SysConfigs), + [application:load(Application) || Config <- SysConfigs, {Application, _} <- Config], + rebar_utils:reread_config(Configs), + Merged = lists:ukeymerge(1, lists:ukeysort(1, CmdOpts), lists:ukeysort(1, CfgOpts)), @@ -229,6 +238,17 @@ select_tests(State, ProjectApps, CmdOpts, CfgOpts) -> end, discover_tests(State, ProjectApps, Opts). +sys_config_list(CmdOpts, CfgOpts) -> + CmdSysConfigs = split_string(proplists:get_value(sys_config, CmdOpts, "")), + case proplists:get_value(sys_config, CfgOpts, []) of + [H | _]=Configs when is_list(H) -> + Configs ++ CmdSysConfigs; + [] -> + CmdSysConfigs; + Configs -> + [Configs | CmdSysConfigs] + end. + discover_tests(State, ProjectApps, Opts) -> case {proplists:get_value(suite, Opts), proplists:get_value(dir, Opts)} of %% no dirs or suites defined, try using `$APP/test` and `$ROOT/test` @@ -647,7 +667,8 @@ ct_opts(_State) -> {verbose, $v, "verbose", boolean, help(verbose)}, {name, undefined, "name", atom, help(name)}, {sname, undefined, "sname", atom, help(sname)}, - {setcookie, undefined, "setcookie", atom, help(setcookie)} + {setcookie, undefined, "setcookie", atom, help(setcookie)}, + {sys_config, undefined, "sys_config", string, help(sys_config)} %% comma-seperated list ]. help(dir) -> @@ -662,6 +683,8 @@ help(label) -> "Test label"; help(config) -> "List of config files"; +help(sys_config) -> + "List of application config files"; help(allow_user_terms) -> "Allow user defined config values in config files"; help(logdir) -> diff --git a/src/rebar_prv_cover.erl b/src/rebar_prv_cover.erl index c915141..464967b 100644 --- a/src/rebar_prv_cover.erl +++ b/src/rebar_prv_cover.erl @@ -296,9 +296,9 @@ strip_coverdir(File) -> cover_compile(State, apps) -> Apps = filter_checkouts(rebar_state:project_apps(State)), AppDirs = app_dirs(Apps), - ExtraDirs = extra_src_dirs(State, Apps), - cover_compile(State, lists:filter(fun(D) -> ec_file:is_dir(D) end, AppDirs ++ ExtraDirs)); + cover_compile(State, lists:filter(fun(D) -> ec_file:is_dir(D) end, AppDirs)); cover_compile(State, Dirs) -> + rebar_utils:update_code(rebar_state:code_paths(State, all_deps), [soft_purge]), %% start the cover server if necessary {ok, CoverPid} = start_cover(), %% redirect cover output @@ -316,27 +316,15 @@ cover_compile(State, Dirs) -> %% print any warnings about modules that failed to cover compile lists:foreach(fun print_cover_warnings/1, lists:flatten(Results)) end - end, Dirs). + end, Dirs), + rebar_utils:cleanup_code_path(rebar_state:code_paths(State, default)), + ok. app_dirs(Apps) -> lists:foldl(fun app_ebin_dirs/2, [], Apps). app_ebin_dirs(App, Acc) -> - AppDir = rebar_app_info:ebin_dir(App), - ExtraDirs = rebar_dir:extra_src_dirs(rebar_app_info:opts(App), []), - OutDir = rebar_app_info:out_dir(App), - [AppDir] ++ [filename:join([OutDir, D]) || D <- ExtraDirs] ++ Acc. - -extra_src_dirs(State, Apps) -> - BaseDir = rebar_state:dir(State), - F = fun(App) -> rebar_app_info:dir(App) == BaseDir end, - %% check that this app hasn't already been dealt with - Extras = case lists:any(F, Apps) of - false -> rebar_dir:extra_src_dirs(rebar_state:opts(State), []); - true -> [] - end, - OutDir = rebar_dir:base_dir(State), - [filename:join([OutDir, "extras", D]) || D <- Extras]. + [rebar_app_info:ebin_dir(App)|Acc]. filter_checkouts(Apps) -> filter_checkouts(Apps, []). diff --git a/src/rebar_prv_path.erl b/src/rebar_prv_path.erl index 4e88496..4259eec 100644 --- a/src/rebar_prv_path.erl +++ b/src/rebar_prv_path.erl @@ -77,15 +77,15 @@ paths([{rel, true}|Rest], Apps, State, Acc) -> base_dir(State) -> io_lib:format("~s", [rebar_dir:base_dir(State)]). bin_dir(State) -> io_lib:format("~s/bin", [rebar_dir:base_dir(State)]). -lib_dir(State) -> io_lib:format("~s/lib", [rebar_dir:base_dir(State)]). +lib_dir(State) -> io_lib:format("~s", [rebar_dir:deps_dir(State)]). rel_dir(State) -> io_lib:format("~s/rel", [rebar_dir:base_dir(State)]). ebin_dirs(Apps, State) -> - lists:map(fun(App) -> io_lib:format("~s/lib/~s/ebin", [rebar_dir:base_dir(State), App]) end, Apps). + lists:map(fun(App) -> io_lib:format("~s/~s/ebin", [rebar_dir:deps_dir(State), App]) end, Apps). priv_dirs(Apps, State) -> - lists:map(fun(App) -> io_lib:format("~s/lib/~s/priv", [rebar_dir:base_dir(State), App]) end, Apps). + lists:map(fun(App) -> io_lib:format("~s/~s/priv", [rebar_dir:deps_dir(State), App]) end, Apps). src_dirs(Apps, State) -> - lists:map(fun(App) -> io_lib:format("~s/lib/~s/src", [rebar_dir:base_dir(State), App]) end, Apps). + lists:map(fun(App) -> io_lib:format("~s/~s/src", [rebar_dir:deps_dir(State), App]) end, Apps). print_paths_if_exist(Paths, State) -> {RawOpts, _} = rebar_state:command_parsed_args(State), diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl index 0ede495..2e6c296 100644 --- a/src/rebar_prv_shell.erl +++ b/src/rebar_prv_shell.erl @@ -108,6 +108,10 @@ shell(State) -> simulate_proc_lib(), true = register(rebar_agent, self()), {ok, GenState} = rebar_agent:init(State), + %% Hack to fool the init process into thinking we have stopped and the normal + %% node start process can go on. Without it, init:get_status() always return + %% '{starting, started}' instead of '{started, started}' + init ! {'EXIT', self(), normal}, gen_server:enter_loop(rebar_agent, [], GenState, {local, rebar_agent}, hibernate). info() -> @@ -328,16 +332,7 @@ reread_config(State) -> no_config -> ok; ConfigList -> - try - [application:set_env(Application, Key, Val) - || Config <- ConfigList, - {Application, Items} <- Config, - {Key, Val} <- Items] - catch _:_ -> - ?ERROR("The configuration file submitted could not be read " - "and will be ignored.", []) - end, - ok + rebar_utils:reread_config(ConfigList) end. boot_apps(Apps) -> @@ -402,7 +397,7 @@ find_config(State) -> no_value -> no_config; Filename when is_list(Filename) -> - consult_config(State, Filename) + rebar_file_utils:consult_config(State, Filename) end. -spec first_value([Fun], State) -> no_value | Value when @@ -410,7 +405,7 @@ find_config(State) -> State :: rebar_state:t(), Fun :: fun ((State) -> no_value | Value). first_value([], _) -> no_value; -first_value([Fun | Rest], State) -> +first_value([Fun | Rest], State) -> case Fun(State) of no_value -> first_value(Rest, State); @@ -441,18 +436,3 @@ find_config_rebar(State) -> find_config_relx(State) -> debug_get_value(sys_config, rebar_state:get(State, relx, []), no_value, "Found config from relx."). - --spec consult_config(rebar_state:t(), string()) -> [[tuple()]]. -consult_config(State, Filename) -> - Fullpath = filename:join(rebar_dir:root_dir(State), Filename), - ?DEBUG("Loading configuration from ~p", [Fullpath]), - Config = case rebar_file_utils:try_consult(Fullpath) of - [T] -> T; - [] -> [] - end, - SubConfigs = [consult_config(State, Entry ++ ".config") || - Entry <- Config, is_list(Entry) - ], - - [Config | lists:merge(SubConfigs)]. - diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 5e1e253..54b135e 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -114,14 +114,14 @@ hex_to_index(State) -> ets:foldl(fun({Pkg, [[]]}, _) when is_binary(Pkg) -> true; - ({Pkg, [Vsns=[Vsn | _Rest]]}, _) when is_binary(Pkg) -> + ({Pkg, [Vsns=[_Vsn | _Rest]]}, _) when is_binary(Pkg) -> %% Verify the package is of the right build tool by checking if the first %% version exists in the table from the foldl above - case ets:member(?PACKAGE_TABLE, {Pkg, Vsn}) of - true -> - ets:insert(?PACKAGE_TABLE, {Pkg, Vsns}); - false -> - true + case [V || V <- Vsns, ets:member(?PACKAGE_TABLE, {Pkg, V})] of + [] -> + true; + Vsns1 -> + ets:insert(?PACKAGE_TABLE, {Pkg, Vsns1}) end; (_, _) -> true diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl index c5c43e4..18c307b 100644 --- a/src/rebar_prv_upgrade.erl +++ b/src/rebar_prv_upgrade.erl @@ -45,7 +45,29 @@ init(State) -> do(State) -> {Args, _} = rebar_state:command_parsed_args(State), Locks = rebar_state:get(State, {locks, default}, []), - Deps = rebar_state:get(State, deps, []), + %% We have 3 sources of dependencies to upgrade from: + %% 1. the top-level rebar.config (in `deps', dep name is an atom) + %% 2. the app-level rebar.config in umbrella apps (in `{deps, default}', + %% where the dep name is an atom) + %% 3. the formatted sources for all after app-parsing (in `{deps, default}', + %% where the reprocessed app name is a binary) + %% + %% The gotcha with these is that the selection of dependencies with a + %% binary name (those that are stable and usable internally) is done with + %% in the profile deps only, but while accounting for locks. + %% Because our job here is to unlock those that have changed, we must + %% instead use the atom-based names, both in `deps' and `{deps, default}', + %% as those are the dependencies that may have changed but have been + %% disregarded by locks. + %% + %% As such, the working set of dependencies is the addition of + %% `deps' and `{deps, default}' entries with an atom name, as those + %% disregard locks and parsed values post-selection altogether. + %% Packages without versions can of course be a single atom. + TopDeps = rebar_state:get(State, deps, []), + ProfileDeps = rebar_state:get(State, {deps, default}, []), + Deps = [Dep || Dep <- TopDeps ++ ProfileDeps, % TopDeps > ProfileDeps + is_atom(Dep) orelse is_atom(element(1, Dep))], Names = parse_names(ec_cnv:to_binary(proplists:get_value(package, Args, <<"">>)), Locks), DepsDict = deps_dict(rebar_state:all_deps(State)), case prepare_locks(Names, Deps, Locks, [], DepsDict) of diff --git a/src/rebar_state.erl b/src/rebar_state.erl index a613a00..bdd4aeb 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -417,7 +417,8 @@ create_logic_providers(ProviderModules, State0) -> catch C:T -> ?DEBUG("~p: ~p ~p", [C, T, erlang:get_stacktrace()]), - throw({error, "Failed creating providers. Run with DEBUG=1 for stacktrace."}) + ?CRASHDUMP("~p: ~p~n~p~n~n~p", [C, T, erlang:get_stacktrace(), State0]), + throw({error, "Failed creating providers. Run with DEBUG=1 for stacktrace or consult rebar3.crashdump."}) end. to_list(#state_t{} = State) -> diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 56a3940..aa9e268 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -69,7 +69,8 @@ check_blacklisted_otp_versions/1, info_useless/2, list_dir/1, - user_agent/0]). + user_agent/0, + reread_config/1]). %% for internal use only -export([otp_release/0]). @@ -412,6 +413,17 @@ user_agent() -> {ok, Vsn} = application:get_key(rebar, vsn), ?FMT("Rebar/~s (OTP/~s)", [Vsn, otp_release()]). +reread_config(ConfigList) -> + try + [application:set_env(Application, Key, Val) + || Config <- ConfigList, + {Application, Items} <- Config, + {Key, Val} <- Items] + catch _:_ -> + ?ERROR("The configuration file submitted could not be read " + "and will be ignored.", []) + end. + %% ==================================================================== %% Internal functions %% ==================================================================== @@ -789,9 +801,13 @@ maybe_ends_in_comma(H) -> end. get_http_vars(Scheme) -> + OS = case os:getenv(atom_to_list(Scheme)) of + Str when is_list(Str) -> Str; + _ -> [] + end, GlobalConfigFile = rebar_dir:global_config(), Config = rebar_config:consult_file(GlobalConfigFile), - proplists:get_value(Scheme, Config, []). + proplists:get_value(Scheme, Config, OS). set_httpc_options() -> set_httpc_options(https_proxy, get_http_vars(https_proxy)), |