diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2018-04-27 07:05:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 07:05:01 -0400 |
commit | d3efb4708cd2303b506988c71ee3671a743b1da2 (patch) | |
tree | 12c647d5f328d9987bdc632683e4351a9b2098fb /src/rebar_prv_local_install.erl | |
parent | 7eca59670f43f5298dd9d126911e583eef7edd0f (diff) | |
parent | df9c769afc4c3480305a1f204b37828531e10331 (diff) |
Merge pull request #1769 from ferd/warn-on-read-only-cachedir
Display warnings when cache dirs are read-only
Diffstat (limited to 'src/rebar_prv_local_install.erl')
-rw-r--r-- | src/rebar_prv_local_install.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/rebar_prv_local_install.erl b/src/rebar_prv_local_install.erl index 282c548..bb019c4 100644 --- a/src/rebar_prv_local_install.erl +++ b/src/rebar_prv_local_install.erl @@ -12,6 +12,7 @@ -export([extract_escript/2]). -include("rebar.hrl"). +-include_lib("providers/include/providers.hrl"). -include_lib("kernel/include/file.hrl"). -define(PROVIDER, install). @@ -54,6 +55,9 @@ do(State) -> end. -spec format_error(any()) -> iolist(). +format_error({non_writeable, Dir}) -> + io_lib:format("Could not write to ~p. Please ensure the path is writeable.", + [Dir]); format_error(Reason) -> io_lib:format("~p", [Reason]). @@ -71,7 +75,12 @@ extract_escript(State, ScriptPath) -> %% And add a rebar3 bin script to ~/.cache/rebar3/bin Opts = rebar_state:opts(State), OutputDir = filename:join(rebar_dir:global_cache_dir(Opts), "lib"), - filelib:ensure_dir(filename:join(OutputDir, "empty")), + case filelib:ensure_dir(filename:join(OutputDir, "empty")) of + ok -> + ok; + {error, Posix} when Posix == eaccess; Posix == enoent -> + throw(?PRV_ERROR({non_writeable, OutputDir})) + end, ?INFO("Extracting rebar3 libs to ~ts...", [OutputDir]), zip:extract(Archive, [{cwd, OutputDir}]), |