title: Makefile (erlang.mk) can't find file that exists
body: <p>I am trying to build a project who's Makefile imports an erlang.mk, that imports other Makefiles and erlang.mks.</p>
  <p>In one erlang.mk I have a <code>grep</code> call inside a conditional in a recipe that looks like this</p>
  <pre><code>if grep ^$$dep$$ $(ERLANG_MK_TMP)/deps.log; then \
  </code></pre>
  <p>and that's printing</p>
  <pre><code>grep: /home/forrealthough/code/rabbitmq-consistent-hash/.erlang.mk/deps.log: No such file or directory
  </code></pre>
  <p>with a return code of 2. If I put this line just before</p>
  <pre><code>if [ ! -f $$ERLANG_MK_TMP/deps.log ]; then echo &quot;File not found!&quot;; fi;\
  </code></pre>
  <p>I get a &quot;File not found!&quot;.</p>
  <p>The file does exist, I can <code>cat</code> it from the same directory and run the same <code>if</code> line without getting a &quot;File not found!&quot;. Its permissions are <code>-rw-rw-r--</code> and I get the same error running <code>make</code> with or without <code>sudo</code>.</p>
  <p>Why can't my script find this file?</p>
  <p>EDIT: I was asked to alter my <code>if</code> test, so here is the relevant section of my script (this is inside a recipe):</p>
  <pre><code>echo file: $(ERLANG_MK_TMP)/deps.log;\
  if [ ! -f $(ERLANG_MK_TMP)/deps.log ]; then echo &quot;File not found!&quot;; fi;\
  if grep ^$$dep$$ $(ERLANG_MK_TMP)/deps.log; then \
  </code></pre>
  <p>and they print</p>
  <pre><code>file: /home/forrealthough/rabbitmq-consistent-hash/.erlang.mk/deps.log
  File not found!
  grep: /home/forrealthough/rabbitmq-consistent-hash/.erlang.mk/deps.log: No such file or directory
  make: *** [erlang.mk:4322: deps] Error 2
  </code></pre>
  <p>Again, the file does exist. <code>grep</code> returns status code=2, which I checked echoing <code>$$?</code>, and it runs the <code>else</code> part of the conditional.</p>
  <p>EDIT 2: If I put a <code>ls $(ERLANG_MK_TMP);\</code> along those other tests it lists every file inside that directory, except deps.log, which, again, is there. This fits other tests I did where I tried to access different files from this script, and deps.log is the only one that couldn't be found.</p>
  <p>I have this same script inside this same project being built as a module of a different project (Another Makefile that imports another erlang.mk that tries to build the Makefile of the project I'm working on). There the script can find the file in question, and it runs normally.</p>