diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 1cefe84..7cf0c7a 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -64,6 +64,11 @@ run(RawArgs) -> %% Convert command strings to atoms CommandAtoms = [list_to_atom(C) || C <- Commands], + %% Determine the location of the rebar executable; important for pulling + %% resources out of the escript + rebar_config:set_global(escript, filename:absname(escript:script_name())), + ?DEBUG("Rebar location: ~p\n", [rebar_config:get_global(escript, undefined)]), + %% Load rebar.config, if it exists process_dir(rebar_utils:get_cwd(), rebar_config:new(), CommandAtoms). diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index ebb3085..c4217cd 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -72,8 +72,9 @@ create(_Config, _) -> case parse_vars(Vars, dict:new()) of {error, Entry} -> Context0 = undefined, - ?ABORT("Failed while processing variables from template ~p. Variable definitions " - "must follow form of [{atom(), term()}]. Failed at: ~p\n", + ?ABORT("Failed while processing variables from template ~p." + "Variable definitions must follow form of " + "[{atom(), term()}]. Failed at: ~p\n", [template_id(), Entry]); Context0 -> ok @@ -110,7 +111,7 @@ create(_Config, _) -> %% cache_escript_files() -> {ok, Files} = escript:foldl(fun(Name, _, GetBin, Acc) -> [{Name, GetBin()} | Acc] end, - [], escript:script_name()), + [], rebar_config:get_global(escript, undefined)), erlang:put(escript_files, Files). @@ -127,7 +128,8 @@ find_escript_templates() -> re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match]. find_disk_templates() -> - HomeFiles = rebar_utils:find_files(filename:join(os:getenv("HOME"), ".rebar/templates"), ?TEMPLATE_RE), + HomeFiles = rebar_utils:find_files(filename:join(os:getenv("HOME"), + ".rebar/templates"), ?TEMPLATE_RE), LocalFiles = rebar_utils:find_files(".", ?TEMPLATE_RE), [{file, F} || F <- HomeFiles++LocalFiles].