<p dir="auto">Tested with this code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="app.setPath(&quot;appData&quot;, './test');
app.setPath(&quot;userData&quot;, './test');"><pre class="notranslate"><code class="notranslate">app.setPath("appData", './test');
app.setPath("userData", './test');
</code></pre></div>
<ul dir="auto">
<li>Electron version: 0.37.2</li>
<li>Operating system: Windows 10</li>
</ul>
<p dir="auto">I'm using <code class="notranslate">app.setPath</code> to change the location where <code class="notranslate">userData</code> and <code class="notranslate">cache</code> are stored and it works (data is saved to the new location). The problem is that even due I set the paths before the <code class="notranslate">ready</code> event, the default location (<code class="notranslate">%APPDATA%/productName</code>) is still created.</p>
<p dir="auto">To test this, I deleted the default path and added to the top of my main.js the following lines:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var fs = require('fs');
console.log('Exists?', fs.existsSync('C:/Users/eran.t/AppData/Roaming/foo'));"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">fs</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'fs'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'Exists?'</span><span class="pl-kos">,</span> <span class="pl-s1">fs</span><span class="pl-kos">.</span><span class="pl-en">existsSync</span><span class="pl-kos">(</span><span class="pl-s">'C:/Users/eran.t/AppData/Roaming/foo'</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">The output was <code class="notranslate">Exists? true</code>, which means the directory was created by some initialization code (it looks like it comes from <a href="https://github.com/atom/electron/blob/c441dd143690aab71a925f0b941a6d9760768fa5/atom/browser/lib/init.coffee#L88-L89">here</a>).</p>
<p dir="auto">Is it possible to move the creation of the directories to when we actually need them (lazy creation), which will give the developer time to change them?</p>
<p dir="auto">To circumvent the issue, one can simply delete the old path using <code class="notranslate">fs.rmdir</code> after changing the path to the new location, but it's not ideal.</p>