notarize icon indicating copy to clipboard operation
notarize copied to clipboard

Error: Failed to staple your application with code: 64 when notarizing on MacOS 13.0 Dev 2

Open r0hin opened this issue 3 years ago • 7 comments

I am trying to notarize the MacOS distributions of my application using the afterSign field for electron-builder, and have been receiving the following error:

Error: Failed to staple your application with code: 64

Usage: stapler staple [-q] [-v] path
        Retrieves a ticket and attaches it to the supported file
        format at path.

Usage: stapler validate [-q] [-v] path
        Validates an existing stapled ticket.

Supported file formats are: UDIF disk images, code-signed executable
bundles, and signed "flat" installer packages.

    at Object.<anonymous> (/Users/rohin/GitHub/parallel2/app/node_modules/electron-notarize/src/staple.ts:16:11)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/rohin/GitHub/parallel2/app/node_modules/electron-notarize/lib/staple.js:4:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

The code I am running in my notarization script is:

const value = await notarize({
    tool: "notarytool",
    appPath: "./dist/mac-arm64/{appName}.app",
    appleId: process.env.APPLE_ID,
    appleIdPassword: process.env.APPLE_ID_PASSWORD,
    teamId: process.env.APPLE_TEAM_ID,
});

The dependency versions are:

"devDependencies": {
    "electron": "^19.0.4",
    "electron-builder": "^23.0.3",
    "electron-notarize": "^1.2.1"
  },

I am running MacOS Ventura 13.0 Developer Beta 2 which could have something to do with it.

Thank you for your help!

r0hin avatar Jun 27 '22 20:06 r0hin

i've got same problem

yhtt2020 avatar Jun 29 '22 05:06 yhtt2020

Same problem here

EDIT: Tried installing the XCode beta, no difference

suan avatar Jul 01 '22 14:07 suan

The accepted answer here might explain it (builds made on a beta version of MacOS aren't accepted) https://developer.apple.com/forums/thread/682597

suan avatar Jul 01 '22 21:07 suan

Stapling works just fine if you skip '-v' arg for 'xcrun stapler staple' that is used within notarize() as last step, as there's no option to skip stapling I just added a catch for quick workaround:

try {
  await electronNotarize.notarize({ ... })
} catch (error) {
  if (error.message?.includes('Failed to staple')) {
    spawn(`xcrun`, ['stapler', 'staple', appPath])
  } else {
    throw error
  }
}

ragauskl avatar Aug 12 '22 17:08 ragauskl

Thanks @ragauskl and the final build after notarization and stapling works fine on Monterey and earlier?

suan avatar Aug 12 '22 18:08 suan

Worked for me on Monterey (built on laptop with Ventura and tested on different computer with Monterey), but haven't tested anything older than that.

My guess would be that it should not cause issues as problem is more likely on beta OS with the validation logic/recognising .app file as a valid file format for stapling, and not a problem with stapling itself

ragauskl avatar Aug 12 '22 18:08 ragauskl

Worked for me too! Here's my approach with spawnSync and status-checking and output:

    if (error.message?.includes('Failed to staple')) {
      console.log('RETRY staple as per https://github.com/electron/electron-notarize/issues/109#issuecomment-1213359106');

      const result = spawnSync('xcrun', ['stapler', 'staple', appPath]);
      console.log('STDOUT: ', result.stdout.toString());
      console.log('STDERR: ', result.stderr.toString());

      if (result.status !== 0) {
        throw new Error(
          `RETRY: Failed to staple your application with return status: ${result.status}`,
        );
      }

      console.log('RETRY: staple succeeded');
    } else {
      throw error;
    }

suan avatar Aug 13 '22 00:08 suan

Duplicate of #31

MarshallOfSound avatar Jun 25 '23 05:06 MarshallOfSound

Not working for me electron-builder 24.6.3 electron 25.0.1

error thown CloudKit query for hrms.app (2/ab4c9d44868c551e173029342b41d4b38ad024f2) failed due to "Record not found". Could not find base64 encoded ticket in response for 2/ab4c9d44868c551e173029342b41d4b38ad024f2 The staple and validate action failed! Error 65.

kartikkalia7 avatar Aug 17 '23 14:08 kartikkalia7

JSON Response is: { records = ( { reason = "Record not found"; recordName = "2/2/081ef50fe92295985a30a12db7dd0acc5d0fe377"; serverErrorCode = "NOT_FOUND"; } ); } CloudKit query for xyz.app (2/081ef50fe...) failed due to "Record not found". Could not find base64 encoded ticket in response for 2/081ef50... The staple and validate action failed! Error 65. failedTask=build stackTrace=Error: Failed to staple your application with code: 65

`require('dotenv').config(); const { notarize } = require('@electron/notarize');

exports.default = async function notarizing(context) { const { electronPlatformName, appOutDir } = context;
if (electronPlatformName !== 'darwin') { return; }

const appName = context.packager.appInfo.productFilename; return await notarize({ appBundleId: 'com.bundleId', appPath: ${appOutDir}/${appName}.app, appleId: appid, appleIdPassword: abc, teamId: 123 }); };`

I have multiple certifcates for different projects

raghavnaphade avatar Sep 05 '23 05:09 raghavnaphade