electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.55k stars 1.73k forks source link

mksquashfs file does not exist & chmod - executable file not found in %PATH% #8006

Open b5414 opened 7 months ago

b5414 commented 7 months ago

I'm building on win64 electron app with vite and build cfg in yml, I have seen: https://www.electron.build/cli#targetconfiguration so my options are snap or appimage, I selected snap and I have these errors (probably related to each others)

• cannot execute chmod error=exec: "chmod": executable file not found in %PATH% after built

⨯ cannot execute cause=exec: "C:\\Users\\Yes\\AppData\\Local\\electron-builder\\Cache\\appimage\\appimage-12.0.1\\linux-x64\\mksquashfs": file does not exist

But, if I do: win+r, paste this path, hit enter, then I see mksquashfs file with 264kb size


Btw, electron-builder --win --config goes fine, I have the valid installer after it

Full log ```powershell > SECRET@1.0.0 build:linux > npm run build && electron-builder --linux --config > SECRET@1.0.0 build > electron-vite build vite v5.0.12 building SSR bundle for production... "dialog" is imported from external module "electron" but never used in "src/main/main.js". "is" is imported from external module "@electron-toolkit/utils" but never used in "src/main/main.js". ✓ 3 modules transformed. out/main/chunks/icon-MiAhUsnU.png 1.54 kB out/main/main.js 4.90 kB ✓ built in 102ms vite v5.0.12 building SSR bundle for production... ✓ 1 modules transformed. out/preload/preload.js 0.83 kB ✓ built in 6ms vite v5.0.12 building for production... ✓ 103 modules transformed. ../../out/renderer/index.html 0.69 kB ../../out/renderer/assets/SECRET_logotype-SuM5IPO2.svg 11.90 kB ../../out/renderer/assets/index-hnH5Houz.css 3.47 kB ../../out/renderer/assets/index-NgBMr6d5.js 328.44 kB ✓ built in 953ms • electron-builder version=24.9.1 os=10.0.19045 • loaded configuration file=F:\github\SECRET\electron-builder.yml • writing effective config file=dist\builder-effective-config.yaml • skipped dependencies rebuild reason=npmRebuild is set to false • packaging platform=linux arch=x64 electron=28.1.4 appOutDir=dist\linux-unpacked • building target=snap arch=x64 file=dist\SECRET_1.0.0_amd64.snap • downloading url=https://github.com/electron-userland/electron-builder-binaries/releases/download/snap-template-4.0-2/snap-template-electron-4.0-2-amd64.tar.7z size=1.5 MB parts=1 • downloaded url=https://github.com/electron-userland/electron-builder-binaries/releases/download/snap-template-4.0-2/snap-template-electron-4.0-2-amd64.tar.7z duration=2.354s • downloading url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z size=1.6 MB parts=1 • downloaded url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z duration=2.635s • cannot execute chmod error=exec: "chmod": executable file not found in %PATH% • cannot execute chmod error=exec: "chmod": executable file not found in %PATH% • cannot execute chmod error=exec: "chmod": executable file not found in %PATH% ⨯ cannot execute cause=exec: "C:\\Users\\Yes\\AppData\\Local\\electron-builder\\Cache\\appimage\\appimage-12.0.1\\linux-x64\\mksquashfs": file does not exist command='C:\Users\Yes\AppData\Local\electron-builder\Cache\appimage\appimage-12.0.1\linux-x64\mksquashfs' 'C:\Users\Yes\AppData\Local\electron-builder\Cache\snap\snap-template-electron-4.0-2-amd64\data-dir' 'C:\Users\Yes\AppData\Local\electron-builder\Cache\snap\snap-template-electron-4.0-2-amd64\desktop-common.sh' 'C:\Users\Yes\AppData\Local\electron-builder\Cache\snap\snap-template-electron-4.0-2-amd64\desktop-gnome-specific.sh' 'C:\Users\Yes\AppData\Local\electron-builder\Cache\snap\snap-template-electron-4.0-2-amd64\desktop-init.sh' 'C:\Users\Yes\AppData\Local\electron-builder\Cache\snap\snap-template-electron-4.0-2-amd64\gnome-platform' 'C:\Users\Yes\AppData\Local\electron-builder\Cache\snap\snap-template-electron-4.0-2-amd64\lib' 'C:\Users\Yes\AppData\Local\electron-builder\Cache\snap\snap-template-electron-4.0-2-amd64\usr' 'F:\github\SECRET\dist\__snap-amd64\command.sh' 'F:\github\SECRET\dist\__snap-amd64\meta' 'F:\github\SECRET\dist\__snap-amd64\scripts' 'F:\github\SECRET\dist\linux-unpacked\chrome_100_percent.pak' 'F:\github\SECRET\dist\linux-unpacked\chrome_200_percent.pak' 'F:\github\SECRET\dist\linux-unpacked\chrome_crashpad_handler' 'F:\github\SECRET\dist\linux-unpacked\SEEECRET' 'F:\github\SECRET\dist\linux-unpacked\icudtl.dat' 'F:\github\SECRET\dist\linux-unpacked\libEGL.so' 'F:\github\SECRET\dist\linux-unpacked\libffmpeg.so' 'F:\github\SECRET\dist\linux-unpacked\libGLESv2.so' 'F:\github\SECRET\dist\linux-unpacked\libvk_swiftshader.so' 'F:\github\SECRET\dist\linux-unpacked\libvulkan.so.1' 'F:\github\SECRET\dist\linux-unpacked\locales' 'F:\github\SECRET\dist\linux-unpacked\resources' 'F:\github\SECRET\dist\linux-unpacked\resources.pak' 'F:\github\SECRET\dist\linux-unpacked\snapshot_blob.bin' 'F:\github\SECRET\dist\linux-unpacked\v8_context_snapshot.bin' 'F:\github\SECRET\dist\linux-unpacked\vk_swiftshader_icd.json' 'F:\github\SECRET\dist\SECRET_1.0.0_amd64.snap' -no-progress -quiet -noappend -comp xz -no-xattrs -no-fragments -all-root workingDir= PS F:\github\SECRET> ``` yes, it's powershell, same with cmd
mmaietta commented 6 months ago

We use import { chmod } from 'fs-extra' and not from fs package directly, does fs-extra not have compatibility with windows?

clairejhaas commented 6 months ago

I'm experiencing the same error that @b5414 is having.

Electron-Builder Version: 24.9.1 Node Version: 20.11.0 Electron Version: 28.2.1 Electron Type (current, beta, nightly): current Target: linux x64.

I also have mksquashfs with 264kb. Both the Snap and AppImage targets for Linux x64 render this same error.

mmaietta commented 6 months ago

Can you try this patch file with patch-package? patches/builder-util+24.9.4.patch

diff --git a/node_modules/builder-util/out/7za.js b/node_modules/builder-util/out/7za.js
index 0e6b7ba..1a7b66d 100644
--- a/node_modules/builder-util/out/7za.js
+++ b/node_modules/builder-util/out/7za.js
@@ -2,14 +2,14 @@
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.getPath7x = exports.getPath7za = void 0;
 const _7zip_bin_1 = require("7zip-bin");
-const fs_extra_1 = require("fs-extra");
+const promises_1 = require("fs/promises");
 async function getPath7za() {
-    await (0, fs_extra_1.chmod)(_7zip_bin_1.path7za, 0o755);
+    await (0, promises_1.chmod)(_7zip_bin_1.path7za, 0o755);
     return _7zip_bin_1.path7za;
 }
 exports.getPath7za = getPath7za;
 async function getPath7x() {
-    await (0, fs_extra_1.chmod)(_7zip_bin_1.path7x, 0o755);
+    await (0, promises_1.chmod)(_7zip_bin_1.path7x, 0o755);
     return _7zip_bin_1.path7x;
 }
 exports.getPath7x = getPath7x;
clairejhaas commented 6 months ago

I do not have 7za.js in my builder-util/out directory. To resole this, I performed a complete reinstall of electron-builder with npm remove electron-builder and npm i electron-builder --save-dev. However, the '7za.js' file is still missing.

I ran C:/myWorkspace/node_modules/builder-util/out dir and got the following output:

Show Full Log

```console Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2/5/2024 10:16 AM 607 arch.d.ts -a---- 2/5/2024 10:16 AM 3216 arch.js -a---- 2/5/2024 10:16 AM 5341 arch.js.map -a---- 2/5/2024 10:16 AM 412 asyncTaskManager.d.ts -a---- 2/5/2024 10:16 AM 2593 asyncTaskManager.js -a---- 2/5/2024 10:16 AM 4761 asyncTaskManager.js.map -a---- 2/5/2024 10:16 AM 211 DebugLogger.d.ts -a---- 2/5/2024 10:16 AM 1497 DebugLogger.js -a---- 2/5/2024 10:16 AM 2551 DebugLogger.js.map -a---- 2/5/2024 10:16 AM 77 deepAssign.d.ts -a---- 2/5/2024 10:16 AM 1307 deepAssign.js -a---- 2/5/2024 10:16 AM 2528 deepAssign.js.map -a---- 2/5/2024 10:16 AM 2746 fs.d.ts -a---- 2/5/2024 10:16 AM 11708 fs.js -a---- 2/5/2024 10:16 AM 20274 fs.js.map -a---- 2/5/2024 10:16 AM 1191 log.d.ts -a---- 2/5/2024 10:16 AM 3808 log.js -a---- 2/5/2024 10:16 AM 7701 log.js.map -a---- 2/5/2024 10:16 AM 336 nodeHttpExecutor.d.ts -a---- 2/5/2024 10:16 AM 1202 nodeHttpExecutor.js -a---- 2/5/2024 10:16 AM 1828 nodeHttpExecutor.js.map -a---- 2/5/2024 10:16 AM 482 promise.d.ts -a---- 2/5/2024 10:16 AM 1727 promise.js -a---- 2/5/2024 10:16 AM 2851 promise.js.map -a---- 2/5/2024 10:16 AM 2899 util.d.ts -a---- 2/5/2024 10:16 AM 15904 util.js -a---- 2/5/2024 10:16 AM 25287 util.js.map ```

Adding the content in a new file called 7za.js and using npx patch-package builder-util yields a mkdir file because I am missing some of the original content in 7za.js.

mmaietta commented 6 months ago

Ah, I was basing off master branch for current code to patch. Can you please try using next version of electron-builder: v24.12.0

clairejhaas commented 6 months ago

I updated electron-builder to v24.12.0, and I am using patch-package v8.0.0. After upgrading, I have the 7za.js file and made the changes suggested. Running npx patch-package electron-builder yields a rmdir error on node:fs:1219 for binding.rmdir(pathModule.toNamespacedPath(path)); The errno is -4082, code EBUSY. However, neither Windows Event Viewer or Task Manager show anything related to the temp file the patch-package created. I also ran this all as administrator, so should have access to the file (AppData/Local/Temp/tmp-####) where the patch info is created.

kirillezhov commented 5 months ago

I have a same problem that @b5414

jeffrson commented 1 month ago

Well, mksquashfs is Linux ELF executable. It cannot be executed natively on Windows.

Such either a Windows version of mksquashfs is needed (or an alternative command from, e.g., https://github.com/AgentD/squashfs-tools-ng) or it should be executed via WSL (what adds another dependency though).