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: app name contains spaces #194

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

Conversation

heyikang
Copy link

@heyikang heyikang commented May 9, 2024

fix #193

@heyikang heyikang requested a review from a team as a code owner May 9, 2024 07:11
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.

It's not clear how this fixes your issue, can you add an explanation in the PR for why the absolute path with a space in it works but the relative path with a space does not?

@kangfenmao
Copy link

kangfenmao commented Aug 27, 2024

App Name: 900 TG

• Notarizing app: /path/to/dist/mac-arm64/900 TG.app
⨯ Failed to display codesign info on your application with code: 1

900 TG.app: No such process
Failed to codesign your application with code: 1
900 TG.app: No such process
900 TG.app: No such process

This PR fixed this issue

@erickzhao erickzhao self-assigned this Sep 4, 2024
@shide1989
Copy link

shide1989 commented Sep 9, 2024

@MarshallOfSound
This PR actually solves the fact that the spawn of the codesign MacOS utility has the correct fullpath to the packaged app.

The previous version would simply try to codesign the packaged app in the current working directory (which is wrong of course) because of wrong arguments passing.
Which causes official Electron boilerplates like (https://www.electronforge.io/templates/vite-+-typescript) to fail to pass the signing step when using yarn make.

@heyikang
Copy link
Author

When notarizing, using a relative path for the codesign parameter and an application name with spaces causes the notarization to fail. This issue does not occur with absolute paths.

@paradite
Copy link

paradite commented Oct 3, 2024

For usage with https://www.npmjs.com/package/patch-package

Create file patches/@electron+notarize+2.3.2.patch with following content:

diff --git a/node_modules/@electron/notarize/lib/check-signature.js b/node_modules/@electron/notarize/lib/check-signature.js
index 324568a..c3d65f8 100644
--- a/node_modules/@electron/notarize/lib/check-signature.js
+++ b/node_modules/@electron/notarize/lib/check-signature.js
@@ -41,16 +41,14 @@ const spawn_1 = require("./spawn");
 const debug_1 = __importDefault(require("debug"));
 const d = (0, debug_1.default)('electron-notarize');
 const codesignDisplay = (opts) => __awaiter(void 0, void 0, void 0, function* () {
-    const result = yield (0, spawn_1.spawn)('codesign', ['-dv', '-vvvv', '--deep', path.basename(opts.appPath)], {
+    const result = yield (0, spawn_1.spawn)('codesign', ['-dv', '-vvvv', '--deep', opts.appPath], {
         cwd: path.dirname(opts.appPath),
     });
     return result;
 });
 const codesign = (opts) => __awaiter(void 0, void 0, void 0, function* () {
     d('attempting to check codesign of app:', opts.appPath);
-    const result = yield (0, spawn_1.spawn)('codesign', ['-vvv', '--deep', '--strict', path.basename(opts.appPath)], {
-        cwd: path.dirname(opts.appPath),
-    });
+    const result = yield (0, spawn_1.spawn)('codesign', ['-vvv', '--deep', '--strict', opts.appPath]);
     return result;
 });
 function checkSignatures(opts) {

@kelsin
Copy link

kelsin commented Nov 10, 2024

I'm seeing this same error even without spaces.

# All of these run in the same folder with App-Name.app

# Does not work
codesign -vvv --deep --strict "App-Name.app"
codesign -vvv --deep --strict "App Name.app"

# Works
codesign -vvv --deep --strict "./App-Name.app"
codesign -vvv --deep --strict "./App Name.app"
codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App-Name.app"
codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App Name.app"

@kelsin
Copy link

kelsin commented Nov 10, 2024

Since this was blocking me I ended up replacing @electron/notarize with a very simple (but no error handling for now) script. In my package.json I have:

"build": {
  "mac": {
    "notarize": false
  },
  "afterSign": "electron/notarize.js"
}

as normal. This is the same as if you are writing your own custom @electron/notarize script. My script however is just:

import { execSync } from "node:child_process";

async function notarizing(context) {
  const { electronPlatformName, appOutDir } = context;

  if (electronPlatformName !== "darwin") {
    return;
  }

  if (!process.env.APPLEIDPASS) {
    return;
  }

  const appName = context.packager.appInfo.productFilename;
  const appPath = `${appOutDir}/${appName}.app`;
  const zipPath = `${appOutDir}/${appName}.zip`;
  const appleId = process.env.APPLE_ID;
  const appleIdPassword = process.env.APPLEIDPASS;
  const teamId = process.env.APPLE_TEAM_ID;

  console.log(
    execSync(`ditto -c -k --keepParent "${appPath}" "${zipPath}"`, {
      encoding: "utf8",
    }),
  );

  console.log(
    execSync(
      `xcrun notarytool submit "${zipPath}" --team-id "${teamId}" --apple-id "${appleId}" --password "${appleIdPassword}" --wait`,
      { encoding: "utf8" },
    ),
  );

  console.log(
    execSync(`xcrun stapler staple "${appPath}"`, { encoding: "utf8" }),
  );
}

export default notarizing;

Use as your own risk and make sure to check what environment variables you are using for CI/etc. This is working in my github actions and now my app is being packaged and notarizing again. Clearly the current logic used to run codesign with only the app bundle basename is not working. Until @electron/notarize updates to fix things I'll be using this.

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.

Notarize fail
7 participants