electron-builder failing on jenkins with: ENOENT: no such file or directory, copyfile elevate.exe

Viewed 1772

I've started working on an old Electron based application. As part of this work, I needed to update many of the packages including electron-builder.

After many tweaks of all the package versions and so on I have the application building on my local machine which is windows 10.

When I push the build to jenkins, and the electron build is attempted I get the following error: ENOENT: no such file or directory, copyfile '/root/.cache/electron-builder/nsis/nsis-3.0.3.2/elevate.exe' -> '/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/electron-packager/win32-x64/MYAPP-win32-x64/resources/elevate.exe'.

I understand that this means the file basically doesn't exist? I don't understand how this would be happening as the same build config was building the app with previous versions of electron-builder but now it isnt. I have gone to the latest version of electron-builder and started working my way back through the versions with no luck.

The jenkins server is CentOS and there is a docker-wine container used. I don't have control over the the actual build server I can only commit my builds.

BUILD ERROR:

electron-builder --win --x64 --ia32 --pd="electron-packager/win32-x64/MYAPP-win32-x64" --config=builder.json

  • electron-builder  version=21.2.0 os=3.10.0-327.18.2.el7.x86_64
  • artifacts will be published if draft release exists  reason=CI detected
  • loaded configuration  file=/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/builder.json
  • building        target=nsis file=release/MYAPP Setup 3.0.3.exe archs=x64, ia32 oneClick=false perMachine=true
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.3.2/nsis-3.0.3.2.7z size=1.4 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.3.2/nsis-3.0.3.2.7z duration=6.237s
  ⨯ ENOENT: no such file or directory, copyfile '/root/.cache/electron-builder/nsis/nsis-3.0.3.2/elevate.exe' -> '/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/electron-packager/win32-x64/MYAPP-win32-x64/resources/elevate.exe'  stackTrace=
                                                                                                                                                                                                                                                                                         Error: ENOENT: no such file or directory, copyfile '/root/.cache/electron-builder/nsis/nsis-3.0.3.2/elevate.exe' -> '/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/electron-packager/win32-x64/MYAPP-win32-x64/resources/elevate.exe'
                                                                                                                                                                                                                                                                                             at processImmediate (internal/timers.js:458:21)
                                                                                                                                                                                                                                                                                         From previous event:
                                                                                                                                                                                                                                                                                             at NsisTarget.buildInstaller (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/app-builder-lib/src/targets/nsis/NsisTarget.ts:203:29)
                                                                                                                                                                                                                                                                                             at processTicksAndRejections (internal/process/task_queues.js:93:5)
                                                                                                                                                                                                                                                                                             at NsisTarget.finishBuild (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/app-builder-lib/src/targets/nsis/NsisTarget.ts:110:7)
                                                                                                                                                                                                                                                                                             at async Promise.all (index 2)
                                                                                                                                                                                                                                                                                             at AsyncTaskManager.awaitTasks (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/builder-util/src/asyncTaskManager.ts:65:25)
                                                                                                                                                                                                                                                                                             at Packager.doBuild (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/app-builder-lib/src/packager.ts:449:5)
                                                                                                                                                                                                                                                                                             at executeFinally (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/builder-util/src/promise.ts:12:14)
                                                                                                                                                                                                                                                                                             at Packager._build (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/app-builder-lib/src/packager.ts:366:31)
                                                                                                                                                                                                                                                                                             at Packager.build (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/app-builder-lib/src/packager.ts:330:12)
                                                                                                                                                                                                                                                                                             at executeFinally (/home/jenkins/workspace/MYAPP_myapp-client_master-BZL24OQAMKV5LCPISXOCH6VJELCMS26NKBSHJ6R43G746JVMSVBQ/node_modules/builder-util/src/promise.ts:12:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp-client@3.0.3 installer:win: `electron-builder --win --x64 --ia32 --pd="electron-packager/win32-x64/MYAPP-win32-x64" --config=builder.json`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myapp-client@3.0.3 installer:win script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-09-01T12_10_26_791Z-debug.log
[Pipeline] 
[Pipeline] // node
[Pipeline] End of Pipeline
[Bitbucket] Notifying commit build result
[Bitbucket] Build result notified
ERROR: script returned exit code 1
Finished: FAILURE

Package versions:

"electron-builder": "21.2.0",
"electron-packager": "7.6.0",
"electron": "8.5.0",

Builder.json:

{
  "win": {
    "icon": "app/ico/icon.ico"
  },
  "nsis": {
    "oneClick": false,
    "perMachine": true,
    "include": "installer.nsh"
  },
  "directories": {
    "output": "release"
  }
}
1 Answers

I ran my build script using a debugger and I found a flag that was my workaround to the issue.

The flag is packElevateHelper as described here, and unless you actually need the elevate functionality you can explicitly omit it and therefore completely avoid the attempt to copy over the file.

For example, your config should have NSIS options that include this property:

  "nsis": {
    "packElevateHelper": false,
  },

Update: I've just confirmed a way to make this pass for me that copies over elevate.exe.

Make sure the binary output folder, where your application .exe file has been created, also contains a resources folder. The copyfile call that tried to copy elevate.exe into the resources folder in your package for installation doesn't ensure that this folder already exists.

In my case, using the programmatic API with prepackaged property set to my binary build output folder, I have simply called the electron-builder build function after I've made the directory like so:

fs.promises.mkdir(path.join(<path_to_binary_folder>, 'resources'));

When the folder exists, the copy command works just fine.

Related