vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.33k stars 1.02k forks source link

Reopen ENOENT when executing bundled binary asset #1516 #1904

Closed boblund closed 1 year ago

boblund commented 1 year ago

What version of pkg are you using?

5.8.1

What version of Node.js are you using?

18.15.0

What operating system are you using?

MaxOS 13.2.1

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

v18.5.0-macos-x64

Describe the Bug

Executing ./dist/cli-macos results in:

Error: spawn /snapshot/testwebview/bin/darwin-amd64/webview ENOENT

Pkg property of package.json:

"pkg": {
   "assets": ["./public/*", "./bin/darwin-amd64/webview"],
   "outputPath": "dist"
}

Source line for spawn:

child_process.spawn(join(__dirname, 'bin/darwin-amd64/webview'), args)

Partial output of DEBUG_PKG=1 pkg . --debug:

> [debug] The file was included as asset content
  /Users/blund/Documents/swdev/testwebview/bin/darwin-amd64/webview

Expected Behavior

Webview is successfully launched by the pkg executable

To Reproduce

Execute steps in bug description.

boblund commented 1 year ago

Here is virtual file system from executing ./dist/cli-macos:

------------------------------- virtual file system
/snapshot
  testwebview                              8478341 
    cli.js                                     531 
    package.json                               312 
    public                                    2149 
      index.html                              1306 
    bin                                    8478341 
      darwin-amd64                         8476192 
        webview                            8476192 
Total size =  8478341
si458 commented 1 year ago

you cant spawn from the included files i created my own backup app which bundles restic, i have to copy the bundle file to somewhere on the drive (my case its just the temp folder) then i have to spawn the exe from the temp folder instead

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

sunknudsen commented 1 year ago

@si458 Would you happen to know why one cannot spawn included asset?

si458 commented 1 year ago

@si458 Would you happen to know why one cannot spawn included asset?

Sadly I'm not sure

The only thing I no is as my other comment says

I have to include the asset (exe in my case) then copy it to a temp folder somewhere, then run it from there

It has something to do with pkg/node not nowhere where it exe is because of its like virtual folder structure (if that makes sense?)

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] commented 1 year ago

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.