Skip to content

Commit

Permalink
Issue 27: Reset ERL_FLAGS before making rebar_utils:sh() calls
Browse files Browse the repository at this point in the history
Make a wrapper for rebar_utils:sh() so that this plugin can invoke elixir/mix commands with ERL_FLAGS set to "". This is done so that the settings of ERL_FLAGS do not influence these commands.

For more information refer to: Issue 27, barrel-db#27
  • Loading branch information
vasu-dasari committed Apr 20, 2018
1 parent a629b81 commit 67db07f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/rebar3_elixir_compile_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ get_details(State) ->

LibDir = case lists:keyfind(lib_dir, 1, Config) of
false ->
{ok, ElixirLibs_} = rebar_utils:sh("elixir -e \"IO.puts :code.lib_dir(:elixir)\"", []),
{ok, ElixirLibs_} = sh("elixir -e \"IO.puts :code.lib_dir(:elixir)\"", []),
filename:join(re:replace(ElixirLibs_, "\\s+", "", [global,{return,list}]), "../");
{lib_dir, Dir2} -> Dir2
end,
Expand Down Expand Up @@ -229,8 +229,8 @@ compile_libs(State, [App | Apps], AddToPath) ->
Profile = profile(Env),
case {ec_file:exists(filename:join(AppDir, "mix.exs")), ec_file:exists(filename:join(AppDir, "rebar.config"))} of
{true, false} ->
rebar_utils:sh(Profile ++ Mix ++ "deps.get", [{cd, AppDir}, {use_stdout, true}]),
rebar_utils:sh(Profile ++ Mix ++ "compile", [{cd, AppDir}, {use_stdout, true}]),
sh(Profile ++ Mix ++ "deps.get", [{cd, AppDir}, {use_stdout, true}]),
sh(Profile ++ Mix ++ "compile", [{cd, AppDir}, {use_stdout, true}]),
LibsDir = libs_dir(AppDir, Env),
{ok, Libs} = file:list_dir_all(LibsDir),
transfer_libs(State, Libs, LibsDir);
Expand Down Expand Up @@ -282,3 +282,6 @@ maybe_copy_dir(Source, Target, CreateNew) ->
ec_file:remove(TargetDir, [recurisve]),
ec_file:copy(Source, TargetDir, [recursive])
end.

sh(Command, Options) ->
rebar_utils:sh(Command, [{env, [{"ERL_FLAGS", ""}]} | Options]).

0 comments on commit 67db07f

Please sign in to comment.