diff options
author | Andrew Thompson <andrew@hijacked.us> | 2013-10-16 19:48:00 -0400 |
---|---|---|
committer | Andrew Thompson <andrew@hijacked.us> | 2013-10-16 19:58:02 -0400 |
commit | d983beafe93a0f58272d3351f12329984541878f (patch) | |
tree | 472784a2f40c8ff3963a7e7ff96f7ae3910db1c5 /src | |
parent | ed88055a750736c5c9807ca4da4803ff8a6aef16 (diff) |
Don't over-aggressively clean the code path in the presence of lib_dir directives
Rebar, when it encounters a lib_dir directive, caches the current code
path, adds the libdir(s) and returns the cached copy of the path. When
rebar has finished processing that directory, it restores the cached
path. This is problematic in the below scenario:
/(lib_dir)->G
A -> B -> C -> D -> E
\-> F -> D -> E
When rebar is finished processing B, it restores the code path to what
it was before it processed B, removing C, D, E and G from the code path.
This means when it comes to process F, neither D or E are in the code
path, so any header includes, rebar plugins or parse transforms will not
be in the code path. Without the lib_dir directive, rebar does no code
path cleanups, so everything works fine.
This change makes rebar only remove the explicit lib_dir code paths it
added and adds an inttest that replicates the above scenario.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_core.erl | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 4d50f4f..2e0768e 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -399,18 +399,19 @@ update_code_path(Config) -> [] -> no_change; Paths -> - OldPath = code:get_path(), LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []), ok = code:add_pathsa(LibPaths), - {old, OldPath} + %% track just the paths we added, so we can remove them without + %% removing other paths added by this dep + {added, LibPaths} end. restore_code_path(no_change) -> ok; -restore_code_path({old, Path}) -> +restore_code_path({added, Paths}) -> %% Verify that all of the paths still exist -- some dynamically %% added paths can get blown away during clean. - true = code:set_path([F || F <- Path, erl_prim_loader_is_file(F)]), + [true = code:del_path(F) || F <- Paths, erl_prim_loader_is_file(F)], ok. erl_prim_loader_is_file(File) -> |