asar
asar copied to clipboard
fails with an error "No such file or directory"
when trying to extract all files from an .asar file I'm getting such an error.
asar extract app.asar ./app
fs.js:565
fs.write = function(fd, buffer, offset, length, position, callback) {
^
Error: ENOENT, no such file or directory '/Users/maddev/Documents/projects/personal/slack/app.asar.unpacked/node_modules/cld-atom-shell/build/Release/cld.node'
at Error (native)
at Object.fs.openSync (fs.js:500:18)
at Object.fs.readFileSync (fs.js:352:15)
at Object.module.exports.readFileSync (/opt/local/lib/node_modules/asar/lib/disk.js:121:19)
at Object.module.exports.extractAll (/opt/local/lib/node_modules/asar/lib/asar.js:115:24)
at Command.<anonymous> (/opt/local/lib/node_modules/asar/bin/asar:53:15)
at Command.listener (/opt/local/lib/node_modules/asar/node_modules/commander/index.js:249:8)
at Command.emit (events.js:110:17)
at Command.parseArgs (/opt/local/lib/node_modules/asar/node_modules/commander/index.js:480:12)
at Command.parse (/opt/local/lib/node_modules/asar/node_modules/commander/index.js:372:21)
what is the problem here? thx
Someone?
I've encountered this problem as well. I don't know why this works, but I went into asar/lib/disk.js
, inside the method readFileSync(...)
, and changed the following:
if (info.unpacked) {
...
} else { ... }
to:
if (false) {
...
} else { ... }
I was then able to unpack the file.
+1 it's not working...Error: ENOENT: no such file or directory when trying to extract
I just ran into this problem myself... I believe it is because the asar has excluded directories from the .asar package and to successfully unpack it you need to have the 'app.asar.unpacked' directory adjacent to the .asar file while extracting.
Can anyone provide an example .asar
file that fails to extract?
A possible workaround is to use absolute paths for the archive
argument.
eg asar.extractAll(__dirname + 'src.asar', 'dest')
@kevinsawicki The only .asar I know of off the top of my head is the GitKraken app.asar on macOS. I just tried this again, and I get the same error.
- Obtain the GitKraken app.asar
- Run
asar e app.asar gitkraken/
Output:
fs.js:583
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/home/me/Desktop/gitkraken/app.asar.unpacked/node_modules/@paulcbetts/system-idle-time/build/Release/system_idle_time.node'
at Object.fs.openSync (fs.js:583:18)
at Object.fs.readFileSync (fs.js:490:33)
at Object.module.exports.readFileSync (/home/me/.config/yarn/global/node_modules/asar/lib/disk.js:111:17)
at filenames.map (/home/me/.config/yarn/global/node_modules/asar/lib/asar.js:214:28)
at Array.map (native)
at Object.module.exports.extractAll (/home/me/.config/yarn/global/node_modules/asar/lib/asar.js:192:20)
at Command.<anonymous> (/home/me/.config/yarn/global/node_modules/asar/bin/asar.js:60:15)
at Command.listener (/home/me/.config/yarn/global/node_modules/commander/index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:194:7)
This issue is pretty straight forward. Basically lots of apps have an app.asar
file but they also have an app.asar.unpacked
folder for some files that shouldn't live in an ASAR. This means that an ASAR file will not extract correctly unless both the app.asar.unpacked
and app.asar
files are in the same location.
@MarshallOfSound Okay, thanks. Learn something new everyday
went into asar/lib/disk.js, inside the method readFileSync(...), and changed the following:
if (info.unpacked) {
// it's an unpacked file, copy it.
buffer = fs.readFileSync(path.join(${filesystem.src}.unpacked
, filename))
} else {
......
}
to
if (info.unpacked) {
// it's an unpacked file, copy it.
//buffer = fs.readFileSync(path.join(${filesystem.src}.unpacked
, filename))
} else {
......
}
as @MarshallOfSound mentioned to unpack the asar archive you would also need a folder app.asar.unpacked
in the same directory as your app.asar
file. Read more here:
And if you don't have the app.asar.unpacked folder WITH the ~original files, then the extract process fails and halts, and you can't easily extract the rest of the files. The above source code hack works, but then probably prevents extract working for files that were listed but not actually packed (for people that want that). It would be nice if asar extract had an additional option to ignore asar.unpacked errors, maybe even by default, or at least some help text specifying on that error, that you can specify this extra option to fully extract all the actually packed files.
This is the exact problem that I had, I placed the app.asar.unpacked folder in the same place as the app.asar and everything worked like a charm. Maybe a clear message telling you to do this could be added ?