electron-webpack icon indicating copy to clipboard operation
electron-webpack copied to clipboard

App name is always "Electron" in dev, very problematic for storing user data

Open mrahhal opened this issue 7 years ago • 7 comments

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));

mrahhal avatar Nov 29 '18 11:11 mrahhal

https://github.com/electron-userland/electron-webpack/issues/243

HaNdTriX avatar Dec 08 '18 15:12 HaNdTriX

Any progress on this issue?

It's impossible to run migrations on dev environment from 'electron-store'...

feafarot avatar Oct 20 '19 09:10 feafarot

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.

UberMouse avatar Apr 17 '20 01:04 UberMouse

Ran into this issue as well

percentcer avatar Apr 18 '20 02:04 percentcer

Facing same issue. Please resolve it

siva-kranthi avatar Apr 29 '20 08:04 siva-kranthi

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))
})()

sabaatworld avatar Aug 04 '20 23:08 sabaatworld

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).

patarapolw avatar Jun 16 '21 09:06 patarapolw