question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IO Error in packaged Electron app

See original GitHub issue

I’m making an Electron app with LevelDB and want to use asar in packaging, but at startup it gives this error:

Uncaught Exception:
OpenError: IO error: ./hypershare.db/LOCK: No such file or directory
    at /Users/gerhard/dev/node/hypershare-app/dist/Hypershare-darwin-x64/Hypershare.app/Contents/Resources/app.asar/node_modules/levelup/lib/levelup.js:119:34
    at /Users/gerhard/dev/node/hypershare-app/dist/Hypershare-darwin-x64/Hypershare.app/Contents/Resources/app.asar/node_modules/leveldown/node_modules/abstract-leveldown/abstract-leveldown.js:39:16

I tried to unpack the file that creates the db, so it isn’t in the .asar file, but it gives the same error.

If I don’t use asar it works though.

How could I avoid this error?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Alecyruscommented, Feb 4, 2019

Thank you, @ralphtheninja . Yeah, I found it. Actually @BrunoBernardino 's answer have solved my problem. Thanks, bro. But I did not notice that I run electron:serve and open the packaged app at the same time.

1reaction
BrunoBernardinocommented, Feb 4, 2019

@Alecyrus here’s the relevant code (sorry, that repo/app got sold and is no longer publicly available):

// renderer.js
const { remote } = require('electron');
const { app } = remote;
const appName = 'Oikon 2';
const appData = `${app.getPath('appData')}/${appName}`;

// This is in another file, but I've simplified for this showcase purpose here
const database = new PouchDB(`${appData}/database`);

Basically the main problem here was PouchDB couldn’t access that app location, but electron can access the appData path, which will depend on the OS.

I hope that helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron App Getting Exception While requiring SQLITE3
1) Your package.json is not well formated (there is no start script for example). New package.json { // there was no begining bracket ......
Read more >
How to solve ERROR: IOError: could not spawn Electron?
This works: using VegaLite, VegaDatasets, ElectronDisplay dataset("cars") |> @vlplot(:point, x=:Acceleration, y=:Miles_per_Gallon, color=:Origin) #But this ...
Read more >
Electron Installation - Developer Guides Overview
Use this doc to install Heap on Electron apps. For web installation instructions, see our web installation guide. ... After you npm install...
Read more >
Electron
Learn how to use Sentry with Electron. ... the SDK cannot automatically inject preload scripts because the script will be missing from the...
Read more >
How to use the electron-log.catchErrors function in ...
To help you get started, we've selected a few electron-log. ... catch and log unhandled errors/rejected promises: electronLog. ... Full package analysis ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found