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

fix: Prevent conflict between parallel makers #3519

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

macdja38
Copy link
Contributor

@macdja38 macdja38 commented Feb 29, 2024

At the moment maker-dmg will simultaneously try to write to out/make/AppName.dmg. This commit changes that to out/make-darwin-arm64/AppName.dmg preventing any conflicts

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:
at the moment maker-dmg fails when run in parallel, for an explanation on why / how / the details see here: #3517

This solution:
We pass a different path into the maker from core for each platform & arch combination, which prevents it from trying to use the same file in an intermediary step.

Downsides:
People might rely on the location of the dmg & zip to be in out/make directly, this would obviously ruin that.

Alternatives considered:
Potentially it would be possible to get maker-dmg to generate a DMG with the required name from the start instead of always generating it with name.dmg and then renaming to name-version-arch.dmg.

code for context maker-dmg/src/MakerDMG.ts

    await this.ensureFile(outPath);
    const dmgConfig = {
      overwrite: true,
      name: appName,
      ...this.config,
      appPath: path.resolve(dir, `${appName}.app`),
      out: path.dirname(outPath),
    };
    const opts = await electronDMG(dmgConfig);
    if (!this.config.name) {
      await this.ensureFile(forgeDefaultOutPath);
      await fs.rename(outPath, forgeDefaultOutPath);
      return [forgeDefaultOutPath];
    }

    return [opts.dmgPath];
    ```

At the moment maker-dmg will simultaneously try to write to `out/make/AppName.dmg`. This commit changes that to `out/make-darwin-arm64/AppName.dmg` preventing any conflicts
@macdja38 macdja38 requested a review from a team as a code owner February 29, 2024 20:23
Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty rough breaking change and IMO not how we want to fix this.

Potentially it would be possible to get maker-dmg to generate a DMG with the required name from the start instead of always generating it with name.dmg and then renaming to name-version-arch.dmg.

This sounds more reasonable

@erickzhao
Copy link
Member

Someone asked me about this on Discord last week and I agree with the above. As you stated in the downsides section in the description, I think this too likely to catch people off-guard.

@macdja38
Copy link
Contributor Author

macdja38 commented Mar 6, 2024

@MarshallOfSound the fallback I mentioned won't work if the user supplies a name via config (though the may have been broken for a long time when building for multiple arches, not sure).

For now I think it's out of scope of this PR to fix that, but I'll leave that up to you.
I'm thinking ideally we'd allow passing a function or string for the name instead of just a string.

current:

{
  name: "@electron-forge/maker-dmg",
  config: {
    name: "AppName",
    overwrite: true,
  },
  platforms: ["darwin"],
},

(this would break because we can't write two AppName.dmg to the same out/make folders. I believe this would have broken before this PR and before 7.0 as well though)

Proposed ability to pass function

{
  name: "@electron-forge/maker-dmg",
  config: {
    name: (version: string, platform: string, arch: string) => `AppName-${arch}-${platform}`,
    overwrite: true,
  },
  platforms: ["darwin"],
}

(idk if we'd want version or not, the user can get that themselves)

@macdja38
Copy link
Contributor Author

macdja38 commented Mar 7, 2024

Updated the PR, also removed the two tests that tested renaming as we don't need to rename anymore.

@macdja38 macdja38 requested a review from MarshallOfSound March 7, 2024 01:51
@macdja38
Copy link
Contributor Author

@MarshallOfSound is there any chance you could take another look?

@macdja38
Copy link
Contributor Author

macdja38 commented May 7, 2024

Updated to resolve merge conflicts

@Innei
Copy link

Innei commented Aug 13, 2024

How about MakerSquirrel or MakerAppImage to solve this problem?

❯ Making a squirrel distributable for win32/x64
❯ Making a squirrel distributable for win32/arm64
✖ Making a squirrel distributable for win32/x64 [FAILED: Failed with exit code: 4294967295
Output:
Couldn't open log file, trying new file: System.IO.IOException: The process cannot access the file 'D:\a\Follow\Follow\node_modules\electron-winstaller\vendor\Squirrel-Releasify.log' because it is being used by another process.
❯ Making a appImage distributable for linux/x64
❯ Making a appImage distributable for linux/arm64
  ⨯ symlink usr/share/icons/hicolor/256x256/apps/Follow.png /home/runner/work/Follow/Follow/out/make/__appImage-x64/Follow.png: file exists
github.com/develar/app-builder/pkg/package-format/appimage.copyIcons.func1.1
	/Volumes/data/Documents/app-builder/pkg/package-format/appimage/appLauncher.go:82
github.com/develar/app-builder/pkg/util.MapAsyncConcurrency.func2
	/Volumes/data/Documents/app-builder/pkg/util/async.go:68
runtime.goexit
	/usr/local/Cellar/go/1.17/libexec/src/runtime/asm_amd64.s:1581  
✖ Making a appImage distributable for linux/arm64 [FAILED: /home/runner/work/Follow/Follow/node_modules/app-builder-bin/linux/x64/app-builder process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
1]
✖ Making distributables [FAILED: /home/runner/work/Follow/Follow/node_modules/app-builder-bin/linux/x64/app-builder process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE

lockiechen added a commit to lockiechen/forge that referenced this pull request Oct 21, 2024
lockiechen added a commit to lockiechen/forge that referenced this pull request Oct 21, 2024
lockiechen added a commit to lockiechen/forge that referenced this pull request Oct 21, 2024
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

Successfully merging this pull request may close these issues.

4 participants