electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

Issue with hdiutil scr create folder when building macOS dmg app

Open eobrien2002 opened this issue 4 months ago • 13 comments

I recently updated my macOS to Sequoia 15.6. I now get this error when running electron-builder:

⨯ unable to execute hdiutil args=["create","-srcfolder","/Users/USER_NAME/Projects/APP_NAME/electron/dist/mac/APP.app","-volname","APP 2.0.1","-anyowners","-nospotlight","-format","UDRW","-quiet","-fs","APFS","/private/var/folders/v6/1v0f8djn5zg06dtqycpw1_nw0000gn/T/t-yY5mMn/2.dmg"] code=undefined error=Exit code: 1. Command failed: hdiutil create -srcfolder /Users/USER_NAME/Projects/APP_NAME/electron/dist/mac/APP.app -volname APP 2.0.1 -anyowners -nospotlight -format UDRW -quiet -fs APFS /private/var/folders/v6/1v0f8djn5zg06dtqycpw1_nw0000gn/T/t-yY5mMn/2.dmg

This is my package.json with build configs:

{ "name": "APP", "productName": "APP", "version": "2.0.1", "description": "APP App", "main": "main.js", "scripts": { "electron": "electron .", "make": "electron-builder", "make:dev": "electron-builder --config.nsis.oneClick=true", "make:prod": "electron-builder --config.nsis.license=build/license.txt --config.nsis.oneClick=false --config.nsis.allowToChangeInstallationDirectory=true" }, "repository": "XXXXX", "publish": { "provider": "github", "releaseType": "release" }, "devDependencies": { "electron": "^37.2.6", "electron-builder": "^26.0.12" }, "author": { "name": "APP Inc", "email": "XXXXXX" }, "dependencies": { "crypto": "^1.0.1", "dotenv": "^16.4.7", "electron-notarize": "^1.2.2", "electron-squirrel-startup": "^1.0.1", "electron-updater": "^6.3.9", "node-wifi": "^2.0.16", "sudo-prompt": "^9.2.1" }, "build": { "appId": "com.XXXX.app", "productName": "XXXX", "directories": { "output": "dist" }, "icon": "./public/icon.ico", "extraResources": [ "./assets", "./public", ".env" ],

  "artifactName": "XXXX-Setup-${version}.exe"

},
"mac": {
  "icon": "./public/icon.icns",
  "category": "public.app-category.utilities",
  "notarize": false,
  "entitlements": "build/entitlements.mac.plist",
  "entitlementsInherit": "build/entitlements.mac.inherit.plist",
  "hardenedRuntime": true,
  "extendInfo": {
    "NSLocationAlwaysAndWhenInUseUsageDescription": "XXXXX.",
    "NSLocalNetworkUsageDescription": "XXXXXX",
    "NSLocationUsageDescription": "XXXX."
  }
}

} }

The error did not occur before updating my mac to the latest OS. Not sure if this is a new mac bug, if its my mac specific, or if electron bug.

I would really appreciate someone take a look as this as i need to package a new app and push to prod this week.

Thanks!!!

eobrien2002 avatar Aug 11 '25 00:08 eobrien2002

EDIT:

It does appear to be an issue introduced by the new update. Adding this config resolved it.

"dmg": { "title": "APP",
"format": "UDZO" }

The issue was from ${productName} ${version} and hdiutil tripping over the space between the two

eobrien2002 avatar Aug 11 '25 01:08 eobrien2002

Same error +1

electron => 28.3.3 electron-builder => 25.1.8

vbingbingv avatar Aug 13 '25 10:08 vbingbingv

same error

  • electron-builder 26.0.12
  • macos sequoia 15.6
  • building dmg universal target

Specifying "format": "UDZO" as mentioned in one of the previous comments doesn't work, it still uses UDRW format

Stashcat-Anis avatar Aug 14 '25 06:08 Stashcat-Anis

@Stashcat-Anis i was able to resolve it by specifying the title field with an app name that had no spaces. I believe the bug is coming from the default title as {App_name} {version}

eobrien2002 avatar Aug 14 '25 12:08 eobrien2002

Same error here when building dmg universal target

  • electron-builder: 26.0.12
  • macos sequoia: 15.6

I face the error only when I let universal in arch from mac target:

"mac": { "category": "public.app-category.music", "icon": "resources/icon.icns", "type": "distribution", "target": [ { "target": "default", "arch": [ "universal" ] } ], "hardenedRuntime": true, "entitlements": "assets/entitlements.mac.plist", "entitlementsInherit": "assets/entitlements.mac.plist", "gatekeeperAssess": false }

RenanSantaterraSonos avatar Aug 18 '25 12:08 RenanSantaterraSonos

same error 🥲

  • "electron-builder": "^26.0.12"
  • macos sequoia 15.6

I also added a dmg configuration and explicitly specified the title along with the format, and that resolved the issue.

zelkovaria avatar Aug 20 '25 06:08 zelkovaria

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment, or this will be closed in 30 days.

github-actions[bot] avatar Sep 20 '25 00:09 github-actions[bot]

@zelkovaria can you show me where you added those dmg configuration and where is this title with the format you mentioned?

{ "appId": "com.apptest.app", "productName": "apptest", "directories": { "output": "dist" }, "files": ["dist-electron/**/*", "dist-frontend/**/*"], "asar": true, "npmRebuild": false, "nodeGypRebuild": false, "win": { "target": "nsis", "icon": "resources/icon.ico", "extraResources": [ { "from": "node_modules/ws/prebuilds", "to": "node_modules/ws/prebuilds" } ] }, "mac": { "category": "public.app-category.music", "icon": "resources/icon.icns", "type": "distribution", "target": [ { "target": "zip", "arch": ["universal"] }, { "target": "dmg", "arch": ["universal"] } ], "hardenedRuntime": true, "entitlements": "public/assets/entitlements.mac.plist", "entitlementsInherit": "public/assets/entitlements.mac.plist", "gatekeeperAssess": false }, "linux": { "icon": "resources/icon.png" } }

RenanSantaterraSonos avatar Oct 09 '25 19:10 RenanSantaterraSonos

@RenanSantaterraSonos I added the DMG config in the electron-builder settings. If you’re using package.json, put it under the top-level "build" key; if you have a separate electron-builder.json, add it at the top level. For example:

"dmg": {
    "format": "UDZO",
    "title": "your service name"
  },

zelkovaria avatar Oct 10 '25 03:10 zelkovaria

It still doesn't work for me :/ My solution was to create a .pkg instead of .dmg:

"mac": {
    "category": "public.app-category.music",
    "icon": "resources/icon.icns",
    "type": "distribution",
    "target": [
      {
        "target": "zip",
        "arch": ["universal"]
      },
      { "target": "pkg", "arch": ["universal"] },
    ],
    "hardenedRuntime": true,
    "entitlements": "public/assets/entitlements.mac.plist",
    "entitlementsInherit": "public/assets/entitlements.mac.plist",
    "gatekeeperAssess": false
  }

RenanSantaterraSonos avatar Oct 10 '25 14:10 RenanSantaterraSonos

@RenanSantaterraSonos Do you still need a DMG specifically? In my project, I’m building for arm64 (Apple Silicon). If your Mac is Intel, the DMG step can fail because the .app for the requested arch never gets produced, which leads to the hdiutil create -srcfolder ... error.

Could you try changing the mac target arch to match your machine? my setting ⬇️

"mac": {
  "target": [
    { "target": "dmg", "arch": ["arm64"] }
  ]
}

zelkovaria avatar Oct 11 '25 04:10 zelkovaria

@zelkovaria I don't need anymore a DMG. Since I'm generating a pkg, it already meets my needs generating a installer file for my app. I tried to update arch to match my machine, but I still got the same error :/

"mac": {
    "category": "public.app-category.music",
    "icon": "resources/icon.icns",
    "type": "distribution",
    "target": [
      {
        "target": "zip",
        "arch": ["universal"]
      },
      { "target": "pkg", "arch": ["universal"] },
      { "target": "dmg", "arch": ["arm64"] }
    ],
    "hardenedRuntime": true,
    "entitlements": "public/assets/entitlements.mac.plist",
    "entitlementsInherit": "public/assets/entitlements.mac.plist",
    "gatekeeperAssess": false
  },
  "dmg": {
    "format": "UDZO",
    "title": "projectname"
  },
unable to execute hdiutil  args=["create","-srcfolder","/Users/example/Documents/projetos/project/electron-app/dist/mac-arm64/ProjectNameTest.app","-volname","projectname","-anyowners","-nospotlight","-format","UDRW","-quiet","-fs","APFS","/private/var/folders/rw/1tldnc3j6538jfzdp9ppmxzx3h7_dp/T/t-ZQLVpY/6.dmg"] code=undefined error=Exit code: 1. Command failed: hdiutil create -srcfolder /Users/example/Documents/projetos/project/electron-app/dist/mac-arm64/ProjectNameTest.app -volname projectname -anyowners -nospotlight -format UDRW -quiet -fs APFS /private/var/folders/rw/1tldnc3j6538jfzdp9ppmxzx3h7_dp/T/t-ZQLVpY/6.dmg

RenanSantaterraSonos avatar Oct 14 '25 14:10 RenanSantaterraSonos

Just updated to macos Tahoe on an M4 macbook and this nasty bug showed up. I think I was on Sonoma before.

Same hdiutil error everyone else is having for DMG creation. Thank you @zelkovaria for the pkg target solution - it's all I need for now!

Still think this is a valid (recurring) bug and sincerely wish the electron dev team would take a look at it. I will provide additional testing or solution experimentation if needed. Already spent hours using AI and many attempts to get this working on my install, what's a few more?

Tetrad10 avatar Nov 20 '25 05:11 Tetrad10