mirror of
https://github.com/correl/rebar.git
synced 2024-11-15 03:00:18 +00:00
Convert the entries in the code path to absolute paths
Rebar will exit with {error,bad_directory} when trying to restore the code path after it has finished working on a subdirectory if there are invalid relative paths in it. The problem was seen when executing the last line of rebar_erlc_compiler:doterl_compile/3 (true = code:set_path(CurrPath)).
This commit is contained in:
parent
90d2ce5e07
commit
58661a92e2
2 changed files with 14 additions and 1 deletions
|
@ -76,6 +76,10 @@ process_commands([Command | Rest]) ->
|
|||
lists:foreach(fun (D) -> erlang:erase({skip_dir, D}) end, skip_dirs()),
|
||||
Operations = erlang:get(operations),
|
||||
|
||||
%% Convert the code path so that all the entries are absolute paths.
|
||||
%% If not, code:set_path() may choke on invalid relative paths when trying
|
||||
%% to restore the code path from inside a subdirectory.
|
||||
true = rebar_utils:expand_code_path(),
|
||||
_ = process_dir(rebar_utils:get_cwd(), rebar_config:new(),
|
||||
Command, sets:new()),
|
||||
case erlang:get(operations) of
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
abort/2,
|
||||
escript_foldl/3,
|
||||
find_executable/1,
|
||||
prop_check/3]).
|
||||
prop_check/3,
|
||||
expand_code_path/0]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
|
@ -156,6 +157,14 @@ find_executable(Name) ->
|
|||
prop_check(true, _, _) -> true;
|
||||
prop_check(false, Msg, Args) -> ?ABORT(Msg, Args).
|
||||
|
||||
%% Convert all the entries in the code path to absolute paths.
|
||||
expand_code_path() ->
|
||||
CodePath = lists:foldl(fun (Path, Acc) ->
|
||||
[filename:absname(Path) | Acc]
|
||||
end, [], code:get_path()),
|
||||
code:set_path(lists:reverse(CodePath)).
|
||||
|
||||
|
||||
%% ====================================================================
|
||||
%% Internal functions
|
||||
%% ====================================================================
|
||||
|
|
Loading…
Reference in a new issue