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

[resolved] Failing to sign app on macOS #1892

Closed
danielfebrero opened this issue Aug 3, 2017 · 10 comments
Closed

[resolved] Failing to sign app on macOS #1892

danielfebrero opened this issue Aug 3, 2017 · 10 comments
Labels

Comments

@danielfebrero
Copy link

danielfebrero commented Aug 3, 2017

  • 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. (/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`

@danielfebrero danielfebrero changed the title Failing to sign app on macOS due to quote in app name Failing to sign app on macOS Aug 3, 2017
@danielfebrero
Copy link
Author

Resolved, it was due to symlinks pointing to inexistent files.

@danielfebrero danielfebrero changed the title Failing to sign app on macOS [resolved] Failing to sign app on macOS Aug 3, 2017
@mharrisn
Copy link

mharrisn commented Aug 7, 2017

What changes were necessary to fix this issue? I'm experiencing the same problem

@danielfebrero
Copy link
Author

danielfebrero commented Aug 7, 2017 via email

@mharrisn
Copy link

mharrisn commented Aug 7, 2017

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?

@danielfebrero
Copy link
Author

danielfebrero commented Aug 7, 2017 via email

@mharrisn
Copy link

mharrisn commented Aug 7, 2017

Thank you for the information I see the same thing. I also don't know why these files are being included in the app. It seem wrong to include the electron lib again. I will need to try the 'two package' solution to see if that could work for me.

In my case I have three broken symlinks:
./dist/mac/MY_APP.app/Contents/Resources/app/node_modules/electron/dist/Electron.app/Contents/Frameworks/Mantle.framework/Headers ./dist/mac/MY_APP.app/Contents/Resources/app/node_modules/electron/dist/Electron.app/Contents/Frameworks/ReactiveCocoa.framework/Headers ./dist/mac/MY_APP.app/Contents/Resources/app/node_modules/electron/dist/Electron.app/Contents/Frameworks/Squirrel.framework/Headers

I deleted them but each time I build, the broken symlinks appear again. But I was able to avoid the error by setting the asar flag in the electron-builder build object in package.json to "asar":true. I hope this help someone else that encounters the issue.

@develar
Copy link
Member

develar commented Aug 7, 2017

Electron must be not in the production deps. Use

npm ls --production

To inspect.

@iamsush
Copy link

iamsush commented Oct 3, 2019

I had the same issue. However, I was able to resolve it by removing all the symlinks from my concerned folder.

Note: Remove all the symlinks found by
find ./YOUR_CONCERNED_FOLDER/ -type l -ls

I hope it would help someone.

@Brijeshlakkad
Copy link

@iamsush Thanks Sushant, you are great! It helped me!

@9oelM
Copy link

9oelM commented 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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants