Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation fails on Windows 11: Cannot open database because the directory does not exist #30

Closed
YanoOfQueenscastle opened this issue Oct 30, 2024 · 6 comments · Fixed by #35

Comments

@YanoOfQueenscastle
Copy link

I am using Windows 11 and when I try to run Finlight-2.0.3.Setup.exe, it fails with following exception:

[Main Instruction]
A JavaScript error occurred in the main process

[Content]
Uncaught Exception:
TypeError: Cannot open database because the directory does not exist
    at new Database (C:\Users\Yano\AppData\Local\finlight\app-2.0.3\resources\app.asar\node_modules\better-sqlite3\lib\database.js:65:9)
    at Kn (C:\Users\Yano\AppData\Local\finlight\app-2.0.3\resources\app.asar\.vite\build\main.js:1:1167)
    at Wo (C:\Users\Yano\AppData\Local\finlight\app-2.0.3\resources\app.asar\.vite\build\main.js:41:84178)
    at Object.<anonymous> (C:\Users\Yano\AppData\Local\finlight\app-2.0.3\resources\app.asar\.vite\build\main.js:41:84070)
    at Module._compile (node:internal/modules/cjs/loader:1373:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1432:10)
    at Module.load (node:internal/modules/cjs/loader:1215:32)
    at Module._load (node:internal/modules/cjs/loader:1031:12)
    at c._load (node:electron/js2c/node_init:2:17025)
    at node:electron/js2c/browser_init:2:129092

I allowed the installer to run when it asked first (but it doesn't ask anymore).

As far as I can tell the C:\Users\Yano\AppData\Local\finlight\app-2.0.3\resources directory exists and contains an app.asar file, but I am not sure about its contents.

Am I missing some dependencies or stuff?

@dsaltares
Copy link
Owner

dsaltares commented Nov 20, 2024

@YanoOfQueenscastle thanks for reporting, sorry it took me a while to respond.

You should have a userSettings.json file inside the finlight user folder. In Windows, this folder should be inside the %APPDATA% directory.

Could you please paste the contents of said file?

For me, it looks like:

{
  "version": 1,
  "settings": {
    "dataPath": "/Users/davidsaltares/Library/CloudStorage/[...]/My Drive/finlight"
  }
}

And can you show me the contents of the dataPath in your system?
Perhaps Windows doesn't give permissions to finlight to access that folder.

@YanoOfQueenscastle
Copy link
Author

Hi David.

Contents of C:\Users\Yano\AppData\Roaming\Finlight\userSettings.json:

{
  "version": 1,
  "settings": {
    "dataPath": "C:\\Users\\Yano\\AppData\\Roaming\\Finlight\\data"
  }
}

The folder C:\Users\Yano\AppData\Roaming\Finlight however does not contain the data folder.

@dsaltares
Copy link
Owner

Thanks @YanoOfQueenscastle, I got my hands on a Windows laptop yesterday and managed to reproduce.

Looks like fileExistsSync for C:\\Users\\Yano\\AppData\\Roaming\\Finlight\\data returns true.

export async function fileExistsSync(filePath: string) {
  try {
    fs.statSync(filePath);
    return true;
  } catch (_e) {
    return false;
  }
}

export function ensureFolderExistsSync(dirPath: string) {
  if (!fileExistsSync(dirPath)) {
    fs.mkdirSync(dirPath, { recursive: true });
  }
}

Looks similar to nodejs/node#9106, which is very weird. I will create the folder regardless of existence, which does not delete anything when the folder exists, because I'm creating it recursively.

@dsaltares
Copy link
Owner

@YanoOfQueenscastle I will soon release a new version with this fix.

@dsaltares
Copy link
Owner

@YanoOfQueenscastle there you go https://github.com/dsaltares/finlight-electron/releases/tag/v2.1.0.

@YanoOfQueenscastle
Copy link
Author

@dsaltares Thanks, this one works nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants