<div dir="ltr">Hi,<div>I'm using this patch which seems to fix my issue.</div><div><br></div><div><div>--- lib/stdlib/src/filelib.erl<span class="" style="white-space:pre">    </span>2014-06-27 12:18:40.000000000 -0400</div>
<div>+++ lib/stdlib/src/filelib.erl<span class="" style="white-space:pre">      </span>2014-06-27 12:19:22.000000000 -0400</div><div>@@ -227,7 +227,7 @@</div><div>     ok;</div><div> ensure_dir(F) -></div><div>     Dir = filename:dirname(F),</div>
<div>-    case do_is_dir(Dir, file) of</div><div>+    case do_is_dir(Dir, directory) of</div><div> <span class="" style="white-space:pre"> </span>true -></div><div> <span class="" style="white-space:pre">       </span>    ok;</div>
<div> <span class="" style="white-space:pre">  </span>false when Dir =:= F -></div><div>@@ -487,6 +487,8 @@</div><div> badpattern(Reason) -></div><div>     error({badpattern,Reason}).</div><div> </div><div>+eval_read_file_info(File, directory) -></div>
<div>+    file:read_file_info(File);</div><div> eval_read_file_info(File, file) -></div><div>     file:read_link_info(File);</div><div> eval_read_file_info(File, erl_prim_loader) -></div></div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Jun 27, 2014 at 6:01 AM, Louis-Philippe Gauthier <span dir="ltr"><<a href="mailto:louis-philippe.gauthier@adgear.com" target="_blank">louis-philippe.gauthier@adgear.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">filelib:ensure_dir/1 is broken when there's a symlink in the path.</span><br style="font-family:arial,sans-serif;font-size:13px">
<div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">the offending commit:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><a href="https://github.com/erlang/otp/commit/f11aabdc9fec593c31e6c4f3fa25c1707e9c35df" target="_blank">https://github.com/erlang/otp/commit/f11aabdc9fec593c31e6c4f3fa25c1707e9c35df</a><br>

</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">e.g.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">

<div>~ $ mkdir test</div><div>~ $ ln -s test test2</div><div><br></div><div>~ $ erl</div><div>Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]</div><div><br></div>

<div>Eshell V6.1  (abort with ^G)</div><div>1> filelib:ensure_dir("test2/foo").</div><div>{error,eexist}</div><div><br></div><div>2> file:make_dir("test2").</div><div>{error,eexist}</div></div><div style="font-family:arial,sans-serif;font-size:13px">

<br></div><div style="font-family:arial,sans-serif;font-size:13px">This happens because eval_read_file_info/2 uses read_link_info/1 instead of read_file_info/1. The file_info type is link instead of folder. </div><div style="font-family:arial,sans-serif;font-size:13px">

<br></div><div style="font-family:arial,sans-serif;font-size:13px">Since it really is a folder, it fails to create the new folder with {error, eexist}.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div>

<div style="font-family:arial,sans-serif;font-size:13px"><div>3> file:read_link_info("test2").</div><div>{ok,{file_info,5,symlink,read_write,</div><div>               {{2014,6,26},{14,52,45}},</div><div>               {{2014,6,26},{14,52,45}},</div>

<div>               {{2014,6,26},{14,52,45}},</div><div>               41453,1,16777220,0,55514582,501,20}}</div><div><br></div><div>vs</div><div><br></div><div>4> file:read_file_info("test2").</div><div>{ok,{file_info,102,directory,read_write,</div>

<div>               {{2014,6,26},{14,53,26}},</div><div>               {{2014,6,26},{14,53,32}},</div><div>               {{2014,6,26},{14,53,32}},</div><div>               16877,3,16777220,0,55514786,501,20}}</div></div>

</div>
</blockquote></div><br></div>