gun icon indicating copy to clipboard operation
gun copied to clipboard

Problem with packaging GUN application using pkg

Open LAKSHYAJAIN16 opened this issue 6 months ago • 3 comments

Hi!

I'm developing an app which requires me to package my gun app using pkg.

The app loads successfully, but every 2 seconds or so I get this error

Error: Cannot write to packaged file
    at writeToSnapshot (pkg/prelude/bootstrap.js:964:16)
    at Object.write (pkg/prelude/bootstrap.js:980:12)
    at writeAll (node:fs:2126:6)
    at node:fs:2191:7
    at zalgoSafe (pkg/prelude/bootstrap.js:432:10)
    at pkg/prelude/bootstrap.js:766:9
    at FSReqCallback.oncomplete (node:fs:201:23)

Here's the code

// gun-server.js
const Gun = require('gun');
require('gun/sea');
require('gun/lib/webrtc');

const http = require('http');
const server = http.createServer().listen(8765);

Gun({ web: server });

console.log('🔫 GunDB peer running at http://localhost:8765/gun');

Terminal

Image

nothing too complicated. how do i resolve this error?

LAKSHYAJAIN16 avatar Jun 08 '25 18:06 LAKSHYAJAIN16

any updates?

LAKSHYAJAIN16 avatar Jun 15 '25 14:06 LAKSHYAJAIN16

@LAKSHYAJAIN16 I don't know what pkg is but guessing it ZIPs gun and then does not like that GUN tries to save data.

So, IDK, you can either run GUN in-memory only (prob not what you want), or complain to pkg to allow data to be saved?

Will close soon, cause this doesn't seem to be a bug with GUN, GUN is doing what it needs to do: saving data to disk.

amark avatar Jun 16 '25 06:06 amark

@amark yeah, pkg is just bundling the application into an executable. even after disabling the radisk attribute it wasn't bundling. was wondering if there was some debugging/metadata storage going on.

LAKSHYAJAIN16 avatar Jun 25 '25 21:06 LAKSHYAJAIN16