Skip to content
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

NSIS does not work on GitHub Actions #8613

Open
minai621 opened this issue Oct 18, 2024 · 8 comments
Open

NSIS does not work on GitHub Actions #8613

minai621 opened this issue Oct 18, 2024 · 8 comments

Comments

@minai621
Copy link

  • Electron-Builder Version: 25.1.8
  • Node Version: 18.x
  • Electron Version: 33.0.1
  • Electron Type (current, beta, nightly): current
  • Target: Windows

When using windows@latest as the GitHub Actions runner OS, the default version of NSIS is 3.10.0.

However, electron-builder requires version 3.0.4.1, and because it cannot find this version, the following error occurs:

exited          command=makensis.exe code=-4058 pid=undefined
⨯ spawn C:\Users\runneradmin\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe ENOENT  failedTask=build stackTrace=Error: spawn C:\Users\runneradmin\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe ENOENT

Here is my action script

name: electron-build
on: push

jobs:
  release:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, windows-latest]
        node-version: [18.x]

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v4

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}

      - name: Install pnpm
        uses: pnpm/action-setup@v2

      - name: Install dependencies
        run: pnpm install --prefer-offline --no-frozen-lockfile

      - name: Deploy native project
        run: pnpm --filter native deploy ./standalone-native

      - name: Build/release Electron app (macOS and Linux)
        if: runner.os != 'Windows'
        env:
          GH_TOKEN: ${{ secrets.github_token }}
          DEBUG: electron-builder
        working-directory: ./standalone-native
        run: pnpm run release

      - name: Build/release Electron app (Windows)
        if: runner.os == 'Windows'
        env:
          GH_TOKEN: ${{ secrets.github_token }}
          DEBUG: electron-builder,electron-builder:*
        working-directory: ./standalone-native
        run: pnpm run build && pnpx electron-builder --win --x64 --publish always

My package.json build configuration is as follows

"build": {
    "publish": {
      "provider": "github",
      "releaseType": "draft"
    },
    "appId": "com.example.product",
    "productName": "product",
    "files": [
      "dist/**/*",
      "node_modules/**/*",
      "package.json",
      "!node_modules/**/*.{ts,map}"
    ],
    "directories": {
      "output": "release"
    },
    "mac": {
      "target": "dmg"
    },
    "win": {
      "target": [
        {
          "target": "nsis",
          "arch": [
            "x64"
          ]
        }
      ]
    },
    "nsis": {
      "oneClick": false,
      "allowToChangeInstallationDirectory": true
    },
    "linux": {
      "target": "AppImage"
    }
  }

It seems that the issue is related to the cache for NSIS electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe ENOENT
Could you help me understand why this issue occurs and what might be causing the cache problem?

@mmaietta
Copy link
Collaborator

Does this reproduce locally as well?

There should be a file at C:\Users\<user name>\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin/makensis.exe

@minai621
Copy link
Author

@mmaietta

Does this reproduce locally as well?

There should be a file at C:\Users\<user name>\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin/makensis.exe

makensis.exe exists locally on my machine.
It can only not be found in the GitHub Actions CI environment.

@mmaietta
Copy link
Collaborator

Tbh, I've never seen this issue before and electron-builder's unit tests run on the latest windows/mac/ubuntu runners without issue, so I'm confused as to why that file doesn't exist in the github runner. Was this working previously for you?

To block you in the interim, can you set this var to the directory that 3.10.0 makensis.exe exists in and see if that resolves your issue for now?

process.env.ELECTRON_BUILDER_NSIS_DIR = <path to directory containing makensis.exe>

@minai621
Copy link
Author

@mmaietta
In local machine testing:

  1. Building for Windows on macOS works normally.
  2. Building for Windows on Windows still fails to spawn makensis.exe (makensis.exe exists in the actual path).

You can reproduce this issue using the GitHub repository at https://github.com/minai621/builder-test

To reproduce on Windows:

  1. Run pnpm install
  2. Run pnpm run release

The error occurs during the NSIS step of the build process.

@mmaietta
Copy link
Collaborator

@beyondkmp would you be willing to take a look at this?

@minai621
Copy link
Author

@mmaietta
I'm facing build failures on my local Windows machine.
There's an ongoing issue where the spawn command fails to execute nsis.exe.
Would you please confirm if Windows builds work properly with these versions

  • Electron-Builder Version: 25.1.8
  • Node Version: 18.x
  • Electron Version: 33.0.1

@mmaietta
Copy link
Collaborator

The GH CI/CD runs on node 18 currently, and all historical CI runs completed successfully on master branch as well, so yes, Windows builds work properly with node 18 and eb 25.1.8. Version of electron shouldn't matter

@beyondkmp
Copy link
Collaborator

beyondkmp commented Oct 29, 2024

Using pnpx will report an error about makensis.exe not being found. Because Windows has a maximum path length of 260 characters. This can be resolved by setting pnpm config -g set virtual-store-dir-max-length 60 to control the length.

pnpm/pnpm#8402 (comment)

https://github.com/beyondkmp/builder-test/blob/4c79f5f0118109876ec2733d48b7a0756e091e1b/.github/workflows/windows-build.yml#L64

However, my recommendation is to avoid using pnpx and instead directly use pnpm run build/release. This way, it will use files directly from node_modules, and the path length won't exceed 260 characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants