question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[resolved] Failing to sign app on macOS

See original GitHub issue
  • Version: 19.18.1
  • Target: macOS

Hi, I think this was not happening in previous versions. I tried to remove the quote and the space from the app name, without success. I never had this problem before and did tons of release 😦

Edit: The problem may come from that I just updated by my system from macOS 10.12.4 to 10.12.6 I just discovered that when removing --string from codesign commands, it works

Edit2: it works when running manually the codesign command, but fails with electron-builder that is know failing on this:

Command failed: spctl --assess --type execute --verbose --ignore-cache --no-cache /Users/danielfebrero/Git/addaps_desktop/dist/mac/Addaps.app /Users/danielfebrero/Git/addaps_desktop/dist/mac/Addaps.app: rejected (invalid destination for symbolic link in bundle) override=security disabled


`Error: Command failed: codesign --verify --deep --verbose=2 --strict /Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app –prepared:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Addap’s beta Helper EH.app –validated:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Addap’s beta Helper EH.app –prepared:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Addap’s beta Helper NP.app –prepared:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Addap’s beta Helper.app –validated:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Addap’s beta Helper NP.app –validated:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Addap’s beta Helper.app –prepared:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Electron Framework.framework/Versions/Current/. –validated:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Electron Framework.framework/Versions/Current/. –prepared:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Mantle.framework/Versions/Current/. –prepared:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Squirrel.framework/Versions/Current/. –validated:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Mantle.framework/Versions/Current/. –validated:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/Squirrel.framework/Versions/Current/. –prepared:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/ReactiveCocoa.framework/Versions/Current/. –validated:/Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app/Contents/Frameworks/ReactiveCocoa.framework/Versions/Current/. /Users/danielfebrero/Git/addaps_desktop/dist/mac/Addap’s beta.app: No such file or directory

at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

From previous event: at MacPackager.sign (/Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/out/macPackager.js:268:11) at /Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/src/macPackager.ts:93:26 From previous event: at /Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/src/macPackager.ts:93:10 at next (native) From previous event: at MacPackager.pack (/Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/out/macPackager.js:190:11) at /Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/src/packager.ts:244:24 From previous event: at Packager.doBuild (/Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/out/packager.js:317:11) at /Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/src/packager.ts:175:52 at next (native) at runCallback (timers.js:574:20) at tryOnImmediate (timers.js:554:5) at processImmediate [as _immediateCallback] (timers.js:533:5) From previous event: at Packager.build (/Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/out/packager.js:236:11) at /Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/src/builder.ts:266:40 at next (native) From previous event: at build (/Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/out/builder.js:69:21) at Object.args [as handler] (/Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/src/cli/cli.ts:46:4) at Object.self.runCommand (/Users/danielfebrero/Git/addaps_desktop/node_modules/yargs/lib/command.js:233:22) at Object.Yargs.self._parseArgs (/Users/danielfebrero/Git/addaps_desktop/node_modules/yargs/yargs.js:1018:24) at Object.get [as argv] (/Users/danielfebrero/Git/addaps_desktop/node_modules/yargs/yargs.js:927:19) at Object.<anonymous> (/Users/danielfebrero/Git/addaps_desktop/node_modules/electron-builder/src/cli/cli.ts:41:15) at Module._compile (module.js:556:32) at Object.Module._extensions…js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.runMain (module.js:590:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3`

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
danielfebrerocommented, Aug 7, 2017

I ran this command from the root folder

find . -type l ! -exec test -e {} ; -print

In my case, I had a node_modules folder (not the original one) full of broken symlinks trying to point to original modules. No idea how it appears there. I deleted it and all goes well.

El 7 ago 2017 13:24 +0200, mharrisn notifications@github.com, escribió:

Your log output looks identical to what I have so I believe I’m having he same problem. How did you determine which symlinks were broken? Which symlinks were broken in your case? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

2reactions
9oelMcommented, Apr 13, 2021

for anyone who’s looking for a script… you can make this as afterPack hook (before signing) if you are using electron-builder.

module.exports = async ({ electronPlatformName, appOutDir, packager }) => {
  // only macos
  if (electronPlatformName !== `darwin`) return;
  const appName = packager.appInfo.productFilename;
  const appPath = `${appOutDir}/${appName}.app`;

  await removeInvalidSymlinks({ appPath });
}

async function removeInvalidSymlinks({
  // string
  appPath,
}) {
  const invalidSymlinksInManyLines = await new Promise((resolve, reject) => {
    exec(`find ${appPath}/Contents -type l ! -exec test -e {} \\; -print`, (error, stdout, stderr) => {
      console.log(`command: find ${appPath}/Contents -type l ! -exec test -e {} \\; -print`)
      if (error) {
        console.error(`error: ${error.message}`);
        return reject(error);
      }
      if (stderr) {
          console.log(`stderr: ${stderr}`);
          return reject(stderr); 
      }
      console.log(`stdout: ${stdout}`);
      resolve(stdout);
    }) 
  });

  console.log("======invalidSymlinksInManyLines======")
  console.log(invalidSymlinksInManyLines)
  console.log("===========================")
  
  const invalidSymlinksInArray = invalidSymlinksInManyLines.split("\n")
    .map((invalidSymlink) => invalidSymlink.trim())
    .filter((maybeEmptyPath) => maybeEmptyPath !== '');
  
  console.log("======invalidSymlinksInArray======")
  console.log(invalidSymlinksInArray)
  console.log("===========================")
  
  const waitUntilAllInvalidSymlinksRemoved = invalidSymlinksInArray.map((invalidSymlink) => {
    return new Promise((resolve) => {
      exec(`rm ${invalidSymlink}`, (error, stdout, stderr) => {
        console.log(`command: rm ${invalidSymlink}`)

        if (error) {
          console.error(`error: ${error.message}`);
          return reject(error);
        }
        if (stderr) {
            console.log(`stderr: ${stderr}`);
            return reject(stderr); 
        }
        console.log(`stdout: ${stdout}`);
        resolve(stdout);
      })
    })
  })

  try {
    await Promise.all(waitUntilAllInvalidSymlinksRemoved);
  } catch (e) {
    console.log(`error happened while removing all invalid symlinks. message: ${e.message}`);
  }

  return;
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving common notarization issues - Apple Developer
You can only notarize apps that you sign with a Developer ID certificate. If you use any other certificate — like a Mac...
Read more >
How to Fix Apple App Store Not Working on Mac - Rapid Repair
Click on the Apple menu and select System Preferences. After that, click on Apple ID and select Overview in the sidebar. Next, click...
Read more >
Failure digitally signing a Mac app outside Xcode
Sorry for answering my own question, but I see no other way as editing the original question would lead to spaghetti text. I...
Read more >
Here's why your Mac cannot connect to App Store - Setapp
You need to sign in. It's possible that your Mac needs you to sign into the App Store, even if you've signed into...
Read more >
Cannot Connect to App Store on Mac? 10 Steps to Fix It
If that doesn't work, try signing out and signing in again from System Preferences > Apple ID > Overview. Step 5. Update Your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found