#`userData` path is incorrect in production build

1 messages · Page 1 of 1 (latest)

sterile kestrel
#

Hello,

I have an Electron app that needs to save quite a few files and user settings. To my understanding, app.getPath("userData") is a good place to do this.

In development, I've been using the userData directory perfectly. However, when I recently tried creating a distributable production build, this is not working quite as expected.

My problem is that the userData path is giving me a path to an .asar file, rather than a writeable directory. Thus, when I try to write files to this path, it fails. The exact path I'm getting it this: C:/Users/myuser/AppData/Local/Programs/electron-app/resources/app.asar

The electron docs suggest that the userData lookup should return a writeable directory, not some random file.

Any ideas?
Thanks!

round wave
#

show the code

sterile kestrel
#
    const file = join(app.getAppPath("userData"), "favorites.json")
    fs.writeFile(file, favorites)
#

I'm trying stuff like this @round wave

round wave
#

app.getAppPath != app.getPath

sterile kestrel
#

oh?

#

Let me take a look

#

Wow, that fixed it. Silly mistake lol

#

thanks a lot