electron-webpack
electron-webpack copied to clipboard
App name is always "Electron" in dev, very problematic for storing user data
When running in dev (electron-webpack dev), app.getName() will always be "Electron". This is a big problem for persisted data because all apps will start writing to the same folder.
I tracked the problem down to this line of code.
https://github.com/electron-userland/electron-webpack/blob/ae2a2f1ab3f2671831eb08169ee1d20aa00dfbb6/packages/electron-webpack/src/dev/dev-runner.ts#L63
There are several resources that say you should give electron the app's folder and not the main.js module. This is the same issue as #61 but it looks abandoned. (For example)
A potential fix would be to use:
args.push(path.join(projectDir, "dist/main"))
Calling app.setName(...) doesn't resolve this.
EDIT:
The following is a workaround:
const appName = 'My App Name';
app.setName(appName);
const appData = app.getPath('appData');
app.setPath('userData', path.join(appData, appName));
https://github.com/electron-userland/electron-webpack/issues/243
Any progress on this issue?
It's impossible to run migrations on dev environment from 'electron-store'...
Any update on this? It's quite annoying. I had my own fork with the change from #243 applied but I ran into issues keeping it working so I've reverted back to this package.
Ran into this issue as well
Facing same issue. Please resolve it
The workaround does not seems to work cause everytime I run the application, the "C:\Users\sabaa\AppData\Roaming\Electron" directory always gets created no matter if I override the name early.
Code for overriding the name:
(function () {
app.setName(APP_NAME)
app.setPath('userData', path.join(app.getPath('appData'), APP_NAME))
})()
Looking in ~/.config, it seems that there is always both ~/.config/Electron and ~/.config/APP_NAME, although Electron is empty.
function setAppName(APP_NAME) {
electron.setName(APP_NAME)
electron.setPath('userData', path.join(electron.getPath('appData'), APP_NAME))
}
setAppName()
app.whenReady().then(() => {
setAppName()
})
~/.config/Electron
└── Dictionaries
1 directory, 0 files
~/.config/APP_NAME
├── Crash Reports
├── data.db
└── Dictionaries
2 directories, 1 file
data.db is something I created myself.
I already included dotfile (tree -a).