asar icon indicating copy to clipboard operation
asar copied to clipboard

Error in getNode while accessing symlink

Open rmartins90 opened this issue 3 months ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @electron/[email protected] for the project I'm working on.

Here's the error I was having, it happened while accessing symlink in macOS library.

 Cannot read properties of undefined (reading 'Resources')  failedTask=build stackTrace=TypeError: Cannot read properties of undefined (reading 'Resources')
    at Filesystem.getNode (<...>/node_modules/@electron/asar/lib/filesystem.js:141:24)
    at Filesystem.getFile (<...>/node_modules/@electron/asar/lib/filesystem.js:149:23)
    at Filesystem.getFile (<...>/node_modules/@electron/asar/lib/filesystem.js:157:19)
    at Object.module.exports.statFile (<...>/node_modules/@electron/asar/lib/asar.js:157:21)
    at buildUnpacked (<...>/node_modules/@electron/universal/src/asar-utils.ts:101:25)
    at Object.exports.mergeASARs (<...>/node_modules/@electron/universal/src/asar-utils.ts:114:3)
    at exports.makeUniversalApp (<...>/node_modules/@electron/universal/src/index.ts:235:13)
    at MacPackager.doPack (<...>/node_modules/app-builder-lib/src/macPackager.ts:140:9)
    at MacPackager.pack (<...>/node_modules/app-builder-lib/src/macPackager.ts:188:9)
    at Packager.doBuild (<...>/node_modules/app-builder-lib/src/packager.ts:445:9)
    at executeFinally (<...>/node_modules/builder-util/src/promise.ts:12:14)
    at Packager._build (<...>/node_modules/app-builder-lib/src/packager.ts:379:31)
    at Packager.build (<...>/node_modules/app-builder-lib/src/packager.ts:340:12)
    at executeFinally (<...>/node_modules/builder-util/src/promise.ts:12:14)

Here is the diff that solved my problem:

diff --git a/node_modules/@electron/asar/lib/filesystem.js b/node_modules/@electron/asar/lib/filesystem.js
index 27b00a1..82d01ef 100644
--- a/node_modules/@electron/asar/lib/filesystem.js
+++ b/node_modules/@electron/asar/lib/filesystem.js
@@ -133,7 +133,7 @@ class Filesystem {
   getNode (p) {
     const node = this.searchNodeFromDirectory(path.dirname(p))
     const name = path.basename(p)
-    if (name) {
+    if (name && node.files && node.files[name])
       return node.files[name]
     } else {
       return node

This issue body was partially generated by patch-package.

rmartins90 avatar Apr 01 '24 23:04 rmartins90