nathanbuchar / electron-settings

📝 A simple persistent user settings framework for Electron.
https://electron-settings.js.org
MIT License
817 stars 60 forks source link

Invalid application name #129

Closed tangb closed 4 years ago

tangb commented 4 years ago

Hello

I'm using this library for a while now and decided to update to latest version and now it seems electron-settings can't find my application name like before. It uses instead "Electron" that is not corresponding to my package.json name field.

I tried to find a way to force it and find getElectron try to use "electron" instance forced in config but with typescript it seems I can't find an Electron object as expected by config electron field. import electron from 'electron' is not allowed, and app is an Electron.App not an electron instance.

I'm not an electron expert and any help would be appreciated, or an exemple ;-)

Than you for your help and thank you for electron-settings that is really useful to use.

Tang

nathanbuchar commented 4 years ago

Hey @tangb! Thanks for using electron-settings :) Can you show me some of your code so that I can better understand what might be going on? Thanks!

tangb commented 4 years ago

Hi, thank you for answered me ;-)

You will find here the main file of my project in which I instanciate electron-settings: https://github.com/tangb/cleep-desktop/blob/typescript/cleepdesktop.ts

On this branch, I only migrate functions with breaking changes (XXXsync). The code is the same that it was using electron-settings v3.0.2

Thank you again for your help

nathanbuchar commented 4 years ago

So if I'm understanding correctly, when you say electron-settings can't find the name of your application, is it that electron-settings is erroneously saving the data to ~/Library/Application Support/Electron (macOS) instead of say ~/Library/Application Support/cleepdesktop?

tangb commented 4 years ago

Yes it is exactly my problem.

It worked with previous version and I find nothing about breaking changes on that. And I tryed to find a way to force the last part of the path (cleepdesktop instead of Electron) without success 😢

nathanbuchar commented 4 years ago

What do you get if you console.log(app.getPath('userData')) between lines 60 and 61?

tangb commented 4 years ago

I got C:\Users\tang\AppData\Roaming\Electron

nathanbuchar commented 4 years ago

What happens if you instead write this?:

app.whenReady(() => {
  console.log(app.getPath('userData'));
});
tangb commented 4 years ago

I got the same result C:\Users\tang\AppData\Roaming\Electron using this piece of code:

app.whenReady().then(() => {
    console.log('=========>', app.getPath('userData'));
});
nathanbuchar commented 4 years ago

So it looks like the user data path for your app is returning C:\Users\tang\AppData\Roaming\Electron instead of C:\Users\tang\AppData\Roaming\cleepdesktop as you're expecting it to. This is all happening outside of electron-settings control, and all electron-settings is doing is saving the settings file to where the app says it should (in this case, C:\Users\tang\AppData\Roaming\Electron.

For now, I'd suggest doing some googling to determine why your user data path is not what you expect it to be. There's probably a simple solution, but at this time I do not believe electron-settings is misbehaving so I'm going to close this ticket, but feel free to let me know if you think it should be reopened

tangb commented 4 years ago

Ok so if I can sum up what you said the problem comes from electron that does not return the correct path. I will try to find a solution

Anyway thank you a lot for your investigations and your help ;-)