From 507281f658f3a25b944b73ef52f9794355f6ed47 Mon Sep 17 00:00:00 2001 From: Kelly McLaughlin Date: Fri, 6 Feb 2015 09:50:47 -0700 Subject: Add packages to code path after installation Fix a bug where packages are not added to the code path after installation. Dependent applications that build from source are not affected by this issue since the build_apps function in rebar_prv_compiler takes care of the code path changes for them. It is only the precompiled packages that suffer from this issue. --- src/rebar_fetch.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index eac2d02..088a49a 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -46,6 +46,7 @@ download_source(AppDir, Source) -> code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), ec_file:remove(filename:absname(AppDir1), [recursive]), ok = ec_file:copy(FromDir, filename:absname(AppDir1), [recursive]), + true = code:add_patha(filename:join(AppDir1, "ebin")), true end catch -- cgit v1.1 From e3ff657dc2b302d2ec81b8439a0d182feb8cad6c Mon Sep 17 00:00:00 2001 From: Kelly McLaughlin Date: Fri, 6 Feb 2015 10:43:51 -0700 Subject: Ensure package ebin directory exists prior to adding to code path --- src/rebar_fetch.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index 088a49a..964ccb3 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -46,7 +46,12 @@ download_source(AppDir, Source) -> code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), ec_file:remove(filename:absname(AppDir1), [recursive]), ok = ec_file:copy(FromDir, filename:absname(AppDir1), [recursive]), - true = code:add_patha(filename:join(AppDir1, "ebin")), + case ec_file:exists(filename:join(AppDir1, "ebin")) of + true -> + true = code:add_patha(filename:join(AppDir1, "ebin")); + false -> + ok + end, true end catch -- cgit v1.1 From 29039bece6f1733099eb6b4eea67f47e37bc24e0 Mon Sep 17 00:00:00 2001 From: Kelly McLaughlin Date: Fri, 6 Feb 2015 11:31:41 -0700 Subject: Change mock_pkg_resource to create ebin directory Change mock_pkg_resource to use rebar_test_utils:create_empty_app so that an ebin directory is created which is a good expectation for a package. Also revert the check in rebar_fetch:download_source to check for an ebin directory before adding it to the code path for package installs. If a package does not have an ebin directory it is probably a good for an exception to be thrown. --- src/rebar_fetch.erl | 7 +------ test/mock_pkg_resource.erl | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index 964ccb3..088a49a 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -46,12 +46,7 @@ download_source(AppDir, Source) -> code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), ec_file:remove(filename:absname(AppDir1), [recursive]), ok = ec_file:copy(FromDir, filename:absname(AppDir1), [recursive]), - case ec_file:exists(filename:join(AppDir1, "ebin")) of - true -> - true = code:add_patha(filename:join(AppDir1, "ebin")); - false -> - ok - end, + true = code:add_patha(filename:join(AppDir1, "ebin")), true end catch diff --git a/test/mock_pkg_resource.erl b/test/mock_pkg_resource.erl index 502e184..ab2c0d3 100644 --- a/test/mock_pkg_resource.erl +++ b/test/mock_pkg_resource.erl @@ -78,7 +78,7 @@ mock_download(Opts) -> App = binary_to_list(AppBin), filelib:ensure_dir(Dir), AppDeps = proplists:get_value({App,Vsn}, Deps, []), - {ok, AppInfo} = rebar_test_utils:create_app( + {ok, AppInfo} = rebar_test_utils:create_empty_app( Dir, App, Vsn, [element(1,D) || D <- AppDeps] ), -- cgit v1.1