electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.52k stars 522 forks source link

Using Git Bash, "electron-forge make" will create folders in the temp directory but will not be able to remove them (failing the command) #3389

Closed justinfarrelldev closed 1 year ago

justinfarrelldev commented 1 year ago

Pre-flight checklist

Electron Forge version

6.4.2

Electron version

24.8.5

Operating system

Windows 11 22H2 (22621.2361)

Last known working Electron Forge version

6.4.2

Expected behavior

A successful output from electron-forge make --platform=win32 (using Squirrel).

Actual behavior

❯ npm run make

> app@1.0.0 make
> env-cmd -f .env.production rm -rf .vite && electron-forge make --platform=win32

✔ Checking your system
✔ Loading configuration
✔ Resolving make targets
  › Making for the following targets: squirrel
❯ Running package command
  ✔ Preparing to package application
  ✔ Running packaging hooks
    ✔ Running generateAssets hook
    ✔ Running prePackage hook
  ❯ Packaging application
    ❯ Packaging for x64 on win32
      ✖ Copying files
        › EPERM: operation not permitted, rmdir 'C:\tmp\electron-packager\win32-x64\ctp-mod-manager-win32-x64-d1Tm1y\resources\app\src\components'
      ◼ Preparing native dependencies
      ◼ Finalizing package
  ◼ Running postPackage hook
◼ Running preMake hook
◼ Making distributables
◼ Running postMake hook

An unhandled rejection has occurred inside Forge:
Error: EPERM: operation not permitted, rmdir 'C:\tmp\electron-packager\win32-x64\app-win32-x64-d1Tm1y\resources\app\src\components'

This happens whether or not I am using env-cmd, and this tmp directory was created fresh (so there was definitely no interference from elevated command prompts, etc). This is just using straight Git Bash, non-elevated through the VS Code integrated terminal (with VS Code not being elevated, either). The components folder is also not empty.

Steps to reproduce

I am using the Vite-Typescript preset.

This is my full make command copied from package.json:

    "make": "env-cmd -f .env.production rm -rf .vite && electron-forge make --platform=win32"

Here is my forge.config.ts:

module.exports = {
  makers: [
    {
      name: '@electron-forge/maker-squirrel',
      config: {},
    },
  ],
  packagerConfig: {
    ignore: ['^\\/public$', '^\\/node_modules$', '^\\/.github$'],
    asar: true,
    tmpdir: 'C:\\tmp',
    overwrite: true,
  },
};

I used overwrite, asar and tmpdir each to try to fix this issue (with none of them fixing it).

Additional information

Output of debug:

❯ DEBUG=electron-forge:* npm run make

> app@1.0.0 make
> env-cmd -f .env.production rm -rf .vite && electron-forge make --platform=win32

⠋ Checking your system
✔ Checking your system
[STARTED] Loading configuration
  electron-forge:project-resolver searching for project in: C:\Users\justin.farrell\Documents\app +0ms
  electron-forge:project-resolver package.json with forge dependency found in C:\Users\justin.farrell\Documents\app\package.json +3ms
[SUCCESS] Loading configuration
[STARTED] Resolving make targets
  electron-forge:require-search searching [
  '@electron-forge/maker-squirrel',
  'C:\\Users\\justin.farrell\\Documents\\app\\@electron-forge\\maker-squirrel',
  'C:\\Users\\justin.farrell\\Documents\\app\\node_modules\\@electron-forge\\maker-squirrel'
] relative to C:\Users\justin.farrell\Documents\app +0ms
  electron-forge:require-search testing @electron-forge/maker-squirrel +1ms
[DATA] Making for the following targets: squirrel
[SUCCESS] Resolving make targets
[STARTED] Running package command
[STARTED] Preparing to package application
  electron-forge:project-resolver searching for project in: C:\Users\justin.farrell\Documents\app +1s
  electron-forge:project-resolver package.json with forge dependency found in C:\Users\justin.farrell\Documents\app\package.json +4ms
[SUCCESS] Preparing to package application
[STARTED] Running packaging hooks
[STARTED] Running generateAssets hook
[SUCCESS] Running generateAssets hook
[STARTED] Running prePackage hook
[SUCCESS] Running prePackage hook
[SUCCESS] Running packaging hooks
[STARTED] Packaging application
[DATA] Determining targets...
  electron-forge:packager packaging with options {
  asar: true,
  overwrite: true,
  ignore: [ '^\\/public$', '^\\/node_modules$', '^\\/.github$' ],
  tmpdir: 'C:\\tmp',
  quiet: true,
  dir: 'C:\\Users\\justin.farrell\\Documents\\app',
  arch: 'x64',
  platform: 'win32',
  afterFinalizePackageTargets: [ [AsyncFunction (anonymous)] ],
  afterComplete: [ [AsyncFunction (anonymous)] ],
  afterCopy: [ [AsyncFunction (anonymous)] ],
  afterExtract: [ [AsyncFunction (anonymous)] ],
  afterPrune: [ [AsyncFunction (anonymous)] ],
  out: 'C:\\Users\\justin.farrell\\Documents\\app\\out',
  electronVersion: '24.8.5'
} +0ms
  electron-forge:packager targets: [ { platform: 'win32', arch: 'x64' } ] +5ms
[STARTED] Packaging for x64 on win32
[STARTED] Copying files
[FAILED] EPERM: operation not permitted, rmdir 'C:\tmp\electron-packager\win32-x64\app-win32-x64-d1Tm1y\resources\app\src\components'
[FAILED] EPERM: operation not permitted, rmdir 'C:\tmp\electron-packager\win32-x64\app-win32-x64-d1Tm1y\resources\app\src\components'
[FAILED] EPERM: operation not permitted, rmdir 'C:\tmp\electron-packager\win32-x64\app-win32-x64-d1Tm1y\resources\app\src\components'
[FAILED] EPERM: operation not permitted, rmdir 'C:\tmp\electron-packager\win32-x64\app-win32-x64-d1Tm1y\resources\app\src\components'

An unhandled rejection has occurred inside Forge:
Error: EPERM: operation not permitted, rmdir 'C:\tmp\electron-packager\win32-x64\app-win32-x64-d1Tm1y\resources\app\src\components'

The rest of the asked-for info is in the "Steps to reproduce" section. I have also tried using npm ci a few times to no avail.

justinfarrelldev commented 1 year ago

Edit: I found the issue within this reproduction and it was not related.

I have managed to reproduce this on a fresh vite-typescript template here: https://github.com/justinfarrelldev/minimal-repro

I have been using Git Bash specifically for this, not sure if it will reproduce on other terminals. The version of git reported within Git Bash is this: git version 2.42.0.windows.1 (I am not sure if there is another way to report a version of Git Bash's terminal specifically)

erikian commented 1 year ago

I couldn't reproduce the issue, could you provide another repro? From the logs you've provided, looks like you can hit this error just with electron-forge package instead of electron-forge make — this would help limit the issue scope.

Are you using Git Bash somewhere else along the process (e.g. to run create-electron-app or to create the tmp directory) or are you just trying to make/package the app with it?

justinfarrelldev commented 1 year ago

I couldn't reproduce the issue, could you provide another repro? From the logs you've provided, looks like you can hit this error just with electron-forge package instead of electron-forge make — this would help limit the issue scope.

Are you using Git Bash somewhere else along the process (e.g. to run create-electron-app or to create the tmp directory) or are you just trying to make/package the app with it?

I figured it out (definitely this time). I think there are permission issues within the Documents folder or something on my setup - when I cloned the repo a level up ("~" in Git Bash), suddenly I was able to make and package just fine. Sorry about that!