-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The asar unpacked files are accessible only with functions like spawn/exec, see https://github.com/electron/electron/issues/6262 #1120
Comments
Please change to |
@develar It changes nothing.. same results.. it looks for I can create a package with electron-builder and regedit if you want to reproduce?! |
@Skywalker13 Are you sure that the whole dir
will be helpful |
Here a complete sample in order to reproduce.. test.zip There are only two files: {
"name": "test",
"productName": "test",
"description": "test",
"author": "test",
"version": "0.0.1",
"main": "index.js",
"scripts": {
"pack": "build --dir",
"dist": "build"
},
"build": {
"appId": "com.test.id",
"asarUnpack": [
"**/node_modules/regedit/**/*"
]
},
"dependencies": {
"regedit": "^2.2.6"
},
"devDependencies": {
"electron": "^1.4.14",
"electron-builder": "^11.3.0"
}
} index.js 'use strict';
const regedit = require ('regedit');
regedit.list ('HKCU\\SOFTWARE', function (err, result) {
if (err) {
console.error (err);
process.exit (1);
}
console.dir (result);
process.exit (0);
}); Outputs: C:\Users\DevBox2\Documents\devel\test>npm i
> electron@1.4.14 postinstall C:\Users\DevBox2\Documents\devel\test\node_modules\electron
> node install.js
test@0.0.1 C:\Users\DevBox2\Documents\devel\test
+-- electron@1.4.14
| +-- electron-download@3.2.0
| | +-- fs-extra@0.30.0
| | | +-- graceful-fs@4.1.11
| | | +-- jsonfile@2.4.0
| | | +-- klaw@1.3.1
| | | +-- path-is-absolute@1.0.1
| | | `-- rimraf@2.5.4
| | | `-- glob@7.1.1
| | | +-- fs.realpath@1.0.0
| | | +-- inflight@1.0.6
| | | | `-- wrappy@1.0.2
| | | `-- once@1.4.0
| | +-- home-path@1.0.3
| | +-- minimist@1.2.0
| | +-- nugget@2.0.1
| | | +-- pretty-bytes@1.0.4
| | | | +-- get-stdin@4.0.1
| | | | `-- meow@3.7.0
| | | | +-- camelcase-keys@2.1.0
| | | | +-- loud-rejection@1.6.0
| | | | | +-- currently-unhandled@0.4.1
| | | | | | `-- array-find-index@1.0.2
| | | | | `-- signal-exit@3.0.2
| | | | +-- map-obj@1.0.1
| | | | +-- redent@1.0.0
| | | | | +-- indent-string@2.1.0
| | | | | `-- strip-indent@1.0.1
| | | | `-- trim-newlines@1.0.0
| | | +-- progress-stream@1.2.0
| | | | +-- speedometer@0.1.4
| | | | `-- through2@0.2.3
| | | | +-- readable-stream@1.1.14
| | | | `-- xtend@2.1.2
| | | | `-- object-keys@0.4.0
| | | +-- request@2.79.0
| | | | +-- aws-sign2@0.6.0
| | | | +-- aws4@1.5.0
| | | | +-- caseless@0.11.0
| | | | +-- combined-stream@1.0.5
| | | | | `-- delayed-stream@1.0.0
| | | | +-- extend@3.0.0
| | | | +-- forever-agent@0.6.1
| | | | +-- form-data@2.1.2
| | | | | `-- asynckit@0.4.0
| | | | +-- har-validator@2.0.6
| | | | | `-- is-my-json-valid@2.15.0
| | | | | +-- generate-function@2.0.0
| | | | | +-- generate-object-property@1.2.0
| | | | | | `-- is-property@1.0.2
| | | | | `-- jsonpointer@4.0.1
| | | | +-- hawk@3.1.3
| | | | | +-- boom@2.10.1
| | | | | +-- cryptiles@2.0.5
| | | | | +-- hoek@2.16.3
| | | | | `-- sntp@1.0.9
| | | | +-- http-signature@1.1.1
| | | | | +-- assert-plus@0.2.0
| | | | | +-- jsprim@1.3.1
| | | | | | +-- extsprintf@1.0.2
| | | | | | +-- json-schema@0.2.3
| | | | | | `-- verror@1.3.6
| | | | | `-- sshpk@1.10.2
| | | | | +-- asn1@0.2.3
| | | | | +-- assert-plus@1.0.0
| | | | | +-- bcrypt-pbkdf@1.0.0
| | | | | +-- dashdash@1.14.1
| | | | | | `-- assert-plus@1.0.0
| | | | | +-- ecc-jsbn@0.1.1
| | | | | +-- getpass@0.1.6
| | | | | | `-- assert-plus@1.0.0
| | | | | +-- jodid25519@1.0.2
| | | | | +-- jsbn@0.1.0
| | | | | `-- tweetnacl@0.14.5
| | | | +-- is-typedarray@1.0.0
| | | | +-- isstream@0.1.2
| | | | +-- json-stringify-safe@5.0.1
| | | | +-- mime-types@2.1.14
| | | | | `-- mime-db@1.26.0
| | | | +-- oauth-sign@0.8.2
| | | | +-- qs@6.3.0
| | | | +-- stringstream@0.0.5
| | | | +-- tough-cookie@2.3.2
| | | | | `-- punycode@1.4.1
| | | | `-- uuid@3.0.1
| | | +-- single-line-log@1.1.2
| | | `-- throttleit@0.0.2
| | +-- path-exists@2.1.0
| | | `-- pinkie-promise@2.0.1
| | | `-- pinkie@2.0.4
| | +-- rc@1.1.6
| | | +-- deep-extend@0.4.1
| | | `-- strip-json-comments@1.0.4
| | `-- sumchecker@1.3.0
| | `-- es6-promise@4.0.5
| `-- extract-zip@1.6.0
| +-- concat-stream@1.5.0
| | +-- inherits@2.0.3
| | +-- readable-stream@2.0.6
| | | +-- isarray@1.0.0
| | | +-- process-nextick-args@1.0.7
| | | `-- util-deprecate@1.0.2
| | `-- typedarray@0.0.6
| +-- debug@0.7.4
| +-- mkdirp@0.5.0
| | `-- minimist@0.0.8
| `-- yauzl@2.4.1
| `-- fd-slicer@1.0.1
| `-- pend@1.2.0
+-- electron-builder@11.3.0
| +-- 7zip-bin@2.0.4
| | `-- 7zip-bin-win@2.0.2
| +-- asar-electron-builder@0.13.5
| | +-- commander@2.9.0
| | | `-- graceful-readlink@1.0.1
| | `-- mkdirp@0.5.1
| | `-- minimist@0.0.8
| +-- bluebird-lst-c@1.0.5
| | `-- bluebird@3.4.7
| +-- chalk@1.1.3
| | +-- ansi-styles@2.2.1
| | +-- escape-string-regexp@1.0.5
| | +-- has-ansi@2.0.0
| | | `-- ansi-regex@2.1.1
| | +-- strip-ansi@3.0.1
| | `-- supports-color@2.0.0
| +-- chromium-pickle-js@0.2.0
| +-- cuint@0.2.2
| +-- electron-builder-core@11.2.1
| +-- electron-builder-http@11.3.0
| +-- electron-builder-util@11.3.0
| | +-- node-emoji@1.5.1
| | | `-- string.prototype.codepointat@0.2.0
| | +-- source-map-support@0.4.9
| | | `-- source-map@0.5.6
| | `-- stat-mode@0.2.2
| +-- electron-download-tf@3.1.0
| | +-- fs-extra@1.0.0
| | `-- path-exists@3.0.0
| +-- electron-macos-sign@1.4.0
| | `-- compare-version@0.1.2
| +-- fs-extra-p@3.0.3
| | `-- fs-extra@1.0.0
| +-- hosted-git-info@2.1.5
| +-- ini@1.3.4
| +-- is-ci@1.0.10
| | `-- ci-info@1.0.0
| +-- isbinaryfile@3.0.2
| +-- js-yaml@3.7.0
| | +-- argparse@1.0.9
| | | `-- sprintf-js@1.0.3
| | `-- esprima@2.7.3
| +-- mime@1.3.4
| +-- minimatch@3.0.3
| | `-- brace-expansion@1.1.6
| | +-- balanced-match@0.4.2
| | `-- concat-map@0.0.1
| +-- normalize-package-data@2.3.5
| | +-- is-builtin-module@1.0.0
| | | `-- builtin-modules@1.1.1
| | `-- validate-npm-package-license@3.0.1
| | +-- spdx-correct@1.0.2
| | | `-- spdx-license-ids@1.2.2
| | `-- spdx-expression-parse@1.0.4
| +-- parse-color@1.0.0
| | `-- color-convert@0.5.3
| +-- plist@2.0.1
| | +-- base64-js@1.1.2
| | +-- xmlbuilder@8.2.2
| | `-- xmldom@0.1.27
| +-- progress@1.1.8
| +-- sanitize-filename@1.6.1
| | `-- truncate-utf8-bytes@1.0.2
| | `-- utf8-byte-length@1.0.4
| +-- semver@5.3.0
| +-- tunnel-agent@0.4.3
| +-- update-notifier@1.0.3
| | +-- boxen@0.6.0
| | | +-- ansi-align@1.1.0
| | | +-- camelcase@2.1.1
| | | +-- cli-boxes@1.0.0
| | | +-- filled-array@1.1.0
| | | +-- object-assign@4.1.0
| | | +-- repeating@2.0.1
| | | | `-- is-finite@1.0.2
| | | `-- widest-line@1.0.0
| | +-- configstore@2.1.0
| | | +-- dot-prop@3.0.0
| | | | `-- is-obj@1.0.1
| | | +-- os-tmpdir@1.0.2
| | | +-- osenv@0.1.4
| | | +-- uuid@2.0.3
| | | `-- write-file-atomic@1.3.1
| | | +-- imurmurhash@0.1.4
| | | `-- slide@1.1.6
| | +-- is-npm@1.0.0
| | +-- latest-version@2.0.0
| | | `-- package-json@2.4.0
| | | +-- got@5.7.1
| | | | +-- create-error-class@3.0.2
| | | | | `-- capture-stack-trace@1.0.0
| | | | +-- duplexer2@0.1.4
| | | | | `-- readable-stream@2.2.2
| | | | | `-- isarray@1.0.0
| | | | +-- is-redirect@1.0.0
| | | | +-- is-retry-allowed@1.1.0
| | | | +-- is-stream@1.1.0
| | | | +-- lowercase-keys@1.0.0
| | | | +-- node-status-codes@1.0.0
| | | | +-- parse-json@2.2.0
| | | | | `-- error-ex@1.3.0
| | | | | `-- is-arrayish@0.2.1
| | | | +-- read-all-stream@3.1.0
| | | | | `-- readable-stream@2.2.2
| | | | | `-- isarray@1.0.0
| | | | +-- readable-stream@2.2.2
| | | | | +-- buffer-shims@1.0.0
| | | | | `-- isarray@1.0.0
| | | | +-- timed-out@3.1.3
| | | | +-- unzip-response@1.0.2
| | | | `-- url-parse-lax@1.0.0
| | | | `-- prepend-http@1.0.4
| | | +-- registry-auth-token@3.1.0
| | | `-- registry-url@3.1.0
| | +-- lazy-req@1.1.0
| | +-- semver-diff@2.1.0
| | `-- xdg-basedir@2.0.0
| | `-- os-homedir@1.0.2
| +-- uuid-1345@0.99.6
| | `-- macaddress@0.2.8
| `-- yargs@6.6.0
| +-- camelcase@3.0.0
| +-- cliui@3.2.0
| | `-- wrap-ansi@2.1.0
| +-- decamelize@1.2.0
| +-- get-caller-file@1.0.2
| +-- os-locale@1.4.0
| | `-- lcid@1.0.0
| | `-- invert-kv@1.0.0
| +-- read-pkg-up@1.0.1
| | +-- find-up@1.1.2
| | `-- read-pkg@1.1.0
| | +-- load-json-file@1.1.0
| | | +-- pify@2.3.0
| | | `-- strip-bom@2.0.0
| | | `-- is-utf8@0.2.1
| | `-- path-type@1.1.0
| +-- require-directory@2.1.1
| +-- require-main-filename@1.0.1
| +-- set-blocking@2.0.0
| +-- string-width@1.0.2
| | +-- code-point-at@1.1.0
| | `-- is-fullwidth-code-point@1.0.0
| | `-- number-is-nan@1.0.1
| +-- which-module@1.0.0
| +-- y18n@3.2.1
| `-- yargs-parser@4.2.1
| `-- camelcase@3.0.0
`-- regedit@2.2.6
+-- debug@2.6.0
| `-- ms@0.7.2
+-- if-async@3.7.4
+-- stream-slicer@0.0.6
`-- through2@0.6.5
+-- readable-stream@1.0.34
| +-- core-util-is@1.0.2
| +-- isarray@0.0.1
| `-- string_decoder@0.10.31
`-- xtend@4.0.1
npm WARN optional Skipping failed optional dependency /7zip-bin/7zip-bin-mac:
npm WARN notsup Not compatible with your operating system or architecture: 7zip-bin-mac@1.0.1
npm WARN optional Skipping failed optional dependency /7zip-bin/7zip-bin-linux:
npm WARN notsup Not compatible with your operating system or architecture: 7zip-bin-linux@1.0.3
npm WARN test@0.0.1 No repository field.
npm WARN test@0.0.1 No license field. pack: C:\Users\DevBox2\Documents\devel\test>npm run pack
> test@0.0.1 pack C:\Users\DevBox2\Documents\devel\test
> build --dir
No native production dependencies
Packaging for win32 x64 using electron 1.4.14 to dist\win-unpacked
⚠️ Application icon is not set, default Electron icon will be used run test.exe: C:\Users\DevBox2\Documents\devel\test>cd dist\win-unpacked
C:\Users\DevBox2\Documents\devel\test\dist\win-unpacked>test.exe
C:\Users\DevBox2\Documents\devel\test\dist\win-unpacked>
Input Error: Can not find script file "C:\Users\DevBox2\Documents\devel\test\dist\win-unpacked\resources\app.asar\node_modules\regedit\vbs\regList.wsf".
{ Error: Command failed: cscript.exe //Nologo C:\Users\DevBox2\Documents\devel\test\dist\win-unpacked\resources\app.asar\node_modules\regedit\vbs\regList.wsf A HKCU\SOFTWARE
at ChildProcess.exithandler (child_process.js:218:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
killed: false,
code: 1,
signal: null,
cmd: 'cscript.exe //Nologo C:\\Users\\DevBox2\\Documents\\devel\\test\\dist\\win-unpacked\\resources\\app.asar\\node_modules\\regedit\\vbs\\regList.wsf A HKCU\\SOFTWARE' }
undefined Folder content: C:\Users\DevBox2\Documents\devel\test\dist\win-unpacked>cd resources
C:\Users\DevBox2\Documents\devel\test\dist\win-unpacked\resources>tree /F
Folder PATH listing for volume system
Volume serial number is 688C-B0FB
C:.
│ app.asar
│ electron.asar
│
└───app.asar.unpacked
└───node_modules
└───regedit
│ .npmignore
│ errors.js
│ index.js
│ LICENSE
│ package.json
│
├───lib
│ cscript.js
│ execFile.js
│ helper.js
│
├───vbs
│ ArchitectureAgnosticRegistry.vbs
│ ArchitectureSpecificRegistry.vbs
│ JsonSafeTest.wsf
│ regCreateKey.wsf
│ regDeleteKey.wsf
│ regList.wsf
│ regListStream.wsf
│ regPutValue.wsf
│ regUtil.vbs
│ util.vbs
│
└───winerrors
error.txt
generatedErrorObjects.js
generateErrorDeclaration.js
generateErrorsJS.js
parsed.json
parseErrors.js
run.sh |
@develar Sorry, forget my last message (deleted here) if you have received this one by email, I was requiring the bad module, it works with node-notifier. |
@develar now I understand why it works with notifier (for example) but not with regedit.
I've tried a stupid script like this (I've a copy of 'use strict';
const path = require ('path');
const {execSync} = require ('child_process');
console.log (__dirname);
const dir = path.join (__dirname, 'dir.exe');
process.stdout.write (execSync (`dir c:\\`, {shell: true})); with: "build": {
"appId": "com.test.id",
"asarUnpack": [
"*.exe"
]
},
In the case of regedit, the IMO, the bug is that when It means that asarUnpack is useful only for files passed to Edit Similar problem with a PNG file in the notifier module with an ugly hack where asar is replaced by asar.unpacked. electron/electron#6262 It seems unacceptable because it needs to modify the modules in order to be usable with asar. |
@Skywalker13 Strange. I am not aware of that. Probably you can use extraResources option and add this directory to search path |
@develar thanks, it looks like a good workaround |
Btw — may be you just need write custom nsis installer script instead of using regedit node module. |
I'm already working with Squirrel.Windows and the app is in production. I'm changing from electron-packager + electron-winstaller to electron-builder in order to support properly macOS and Linux too. Changing for NSIS breaks the auto-update for our customers. I'm using regedit in the squirrel script and I use a module which uses regedit too to retrieve regional settings on Windows. Then, it's not used only for installing. |
@develar I've make a module in order to handle this problem with only one line of code to add in the electron project, see https://github.com/epsitec-sa/hazardous For example, with my sample: 'use strict';
require ('hazardous');
const regedit = require ('regedit');
regedit.list ('HKCU\\SOFTWARE', function (err, result) {
if (err) {
console.error (err);
process.exit (1);
}
console.dir (result);
process.exit (0);
}); The only thing to do is to add |
It feels like the hazardous library should be the normal behavior for these functions. Is there a reason it's not? In our case we're exec'ing a java on the system and running a JAR file that's packaged with the app. It's convoluted but saved us development effort by not having to rewrite some functions in node. |
When actually this will be fixed, so no need any shaman magic with node_modules? |
Hello,
There are two problems. The first one is that the regedit module is not saved automatically in
app.asar.unpacked
The second problem is that it's not really working even if I set manually the
asarUnpack
value.The regedit module spawn/exec (I don't know exactly)
wsf
andvbs
scripts.In the
win.asar.unpacked
directory I can find this module with all files. It looks perfect...C:\blabla\win-ia32-unpacked\resources\app.asar.unpacked\node_modules\regedit
.But when executing.. it's not working at all...
Why the spawn/exec calls are not looking in the
app.asar.unpacked
directory?asarUnpack
seems useless if it's necessary to handle manually the location for the spawns. I'm doing something wrong?Thanks for help
Regards
The text was updated successfully, but these errors were encountered: