Electron-builder: TypeError when publishing to Github

Created on 9 Feb 2017  ·  18Comments  ·  Source: electron-userland/electron-builder

  • Version: 3.3.0

  • Target: Mac


I am getting an error when attempting to publish to a Github repo. This is part of the stack trace (let me know if you need more of it):

TypeError: Cannot read property 'url' of null
    at /Users/ben.march/content-manager/node_modules/electron-builder/src/publish/PublishManager.ts:79:8
    at next (native)
From previous event:
    at PublishManager.packager.addAfterPackHandler (/Users/ben.march/content-manager/node_modules/electron-builder/out/publish/PublishManager.js:273:29)
    at default.each.it (/Users/ben.march/content-manager/node_modules/electron-builder/src/packager.ts:376:49)
From previous event:
    at Packager.afterPack (/Users/ben.march/content-manager/node_modules/electron-builder/src/packager.ts:376:28)
    at /Users/ben.march/content-manager/node_modules/electron-builder/src/platformPackager.ts:231:21
    at next (native)
    at tryOnImmediate (timers.js:543:15)
    at processImmediate [as _immediateCallback] (timers.js:523:5)

and here is my publish config:

"build": {
    "asar": false,
    "appId": "org.******.ContentManager",
    "mac": {
      "publish": [{
        "provider": "github",
        "host": "git.*******.org",
        "repo": "*****/content-manager"
      }],
      "category": "public.app-category.utility"
    },
    "dmg": {
      "title": "Content Manager"
    }
  }

I did some debugging and it appears that publishConfigs === [null], so publishConfig === null which is why it is throwing the TypeError.

Thanks,
Ben

bug deployment

All 18 comments

Do you use GitHub Enterprise?

Yes, I saw that you added that feature today and the timing couldn't have been better. I would like try this with hosted GH to rule that out but my company doesn't allow that.

Ok, I will add test case (thanks for clear report and provided configs) to investigate.

Thank you for your quick response!

To give you a bit more information:

I created a private repo on hosted GH and used the minimum config "publish": [{"provider": "github"}] and that worked.

Then I added the repository field to package.json and it still worked.

Then I added the "repo" option to the publish config and it still worked.

When I changed the repository field in package.json to the GH Enterprise URL (keeping everything else the same) it threw the error.

When I changed the "repo" option to match the GH Enterprise repo it threw the error.

It looks like the repository field takes precedent over the "repo" option, and it has a hard time parsing the GH Enterprise URL.

Hope this helps.

Hey @develar, I noticed that a few GitHub changes were released a few days ago. Was this included or is it still open?

Thanks,
Ben

Some changes were performed, but I haven't yet verified issue.

I'm having this problem as of v13.9.0.

Please check 14.4.2.

Still getting an error with 14.4.2 (and 14.5.0) but it is a different error:

Error: Cannot detect repository by .git/config. Please specify "repository" in the package.json (https://docs.npmjs.com/files/package.json#repository).
Please see https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts
    at /Users/*****/node_modules/electron-builder/src/publish/publisher.ts:29:13
    at next (native)

I am using the same config as in the original post, and I have added the repository field to package.json. I tried both the shorthand form "repository": "https://git.****.org/****/content-manager.git" and the longer form:

"repository": {
  "type": "git",
  "url": "https://git.****.org/****/content-manager.git"
}

@benmarch Is it full error stacktrace?

Here is the whole thing:

No native production dependencies
⚠️  Packaging using asar archive is disabled — it is strongly not recommended.
Please enable asar and use asarUnpack to unpack files that must be externally available.
Packaging for darwin x64 using electron 1.4.6 to dist/mac
Error: Cannot detect repository by .git/config. Please specify "repository" in the package.json (https://docs.npmjs.com/files/package.json#repository).
Please see https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts
    at /Users/*****/node_modules/electron-builder/src/publish/publisher.ts:29:13
    at next (native)
From previous event:
    at getInfo (/Users/*****/node_modules/electron-builder/out/publish/publisher.js:32:30)
    at /Users/*****/node_modules/electron-builder/src/publish/publisher.ts:40:24
    at next (native)
From previous event:
    at getResolvedPublishConfig (/Users/*****/node_modules/electron-builder/out/publish/publisher.js:88:21)
    at /Users/*****/node_modules/electron-builder/src/publish/PublishManager.ts:394:95
    at tryOnImmediate (timers.js:543:15)
    at processImmediate [as _immediateCallback] (timers.js:523:5)
From previous event:
    at /Users/*****/node_modules/electron-builder/src/publish/PublishManager.ts:394:64
    at next (native)
From previous event:
    at getPublishConfigs (/Users/*****/node_modules/electron-builder/out/publish/PublishManager.js:186:22)
    at /Users/*****/node_modules/electron-builder/src/publish/PublishManager.ts:71:83
    at next (native)
From previous event:
    at PublishManager.packager.addAfterPackHandler (/Users/*****/node_modules/electron-builder/out/publish/PublishManager.js:342:29)
    at default.each.it (/Users/*****/node_modules/electron-builder/src/packager.ts:391:49)
From previous event:
    at Packager.afterPack (/Users/*****/node_modules/electron-builder/src/packager.ts:391:28)
    at /Users/*****/node_modules/electron-builder/src/platformPackager.ts:220:21
From previous event:
    at MacPackager.doPack (/Users/*****/node_modules/electron-builder/out/platformPackager.js:258:11)
    at /Users/*****/node_modules/electron-builder/src/macPackager.ts:80:71
    at next (native)
From previous event:
    at MacPackager.pack (/Users/*****/node_modules/electron-builder/out/macPackager.js:173:11)
    at /Users/*****/node_modules/electron-builder/src/packager.ts:234:22
From previous event:
    at Packager.doBuild (/Users/*****/node_modules/electron-builder/out/packager.js:351:11)
    at /Users/*****/node_modules/electron-builder/src/packager.ts:162:38
    at next (native)
    at tryOnImmediate (timers.js:543:15)
    at processImmediate [as _immediateCallback] (timers.js:523:5)
From previous event:
    at Packager.build (/Users/*****/node_modules/electron-builder/out/packager.js:257:11)
    at /Users/*****/node_modules/electron-builder/src/builder.ts:217:33
    at next (native)
From previous event:
    at build (/Users/*****/node_modules/electron-builder/out/builder.js:70:21)
    at Object.<anonymous> (/Users/*****/node_modules/electron-builder/out/cli/build-cli.js:71:41)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:456:3

npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "release"
npm ERR! node v6.2.1
npm ERR! npm  v3.9.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] release: `GH_TOKEN=****** build --mac`
npm ERR! Exit status 255
npm ERR! 
npm ERR! Failed at the [email protected] release script 'GH_TOKEN=******* build --mac'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the content-manager package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     GH_TOKEN=****** build --mac
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs content-manager
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls content-manager
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/*****/npm-debug.log

@benmarch Error is clear. Since you use Github Enterprise, hosted-git-info cannot parse URL. So, you must explicitly set repo and owner options.

"publish": [{
        "provider": "github",
        "host": "git.*******.org",
        "repo": "*****/content-manager"
        "owner": "OWNER"
      }],

Hey @develar so it looks like my issue was that I was not specifying "owner". Honestly, I wasn't sure how owner played into the config, so I was specifying the "repo" as "owner/repoName" instead of "owner": "owner", "repo": "repoName". Would you mind updating the wiki in the GitHub section to explain how that works?

There appears to be one more issue, the request is adding an extra slash "/" in the releases URL, which is causing the request to fail (I'm not sure why an extra slash causes it to fail, but it is). This is the URL that is being requested, and it always returns a 404: https://git.mycompany.org/api/v3//repos/owner/content-manager/releases. When I test in the browser it gives me the same 404 response. When I remove the extra slash after v3 in the browser it works as expected.

Thank you for all your help!!

Honestly, I wasn't sure how owner played into the config, so I was specifying the "repo" as "owner/repoName" instead of "owner": "owner", "repo": "repoName".

This form should be accepted also. To be fixed.

There appears to be one more issue, the request is adding an extra slash "/" in the releases URL

Will check.

Thanks for clear answers. Please try 15.0.0

Thanks, @develar! It is working now!

Just as a note, I still have to specify the owner field, otherwise it seems to use repoName as the owner. So if I just specify "repo" as "owner/content-manager" then the request URL becomes: https://git.*****.org/api/v3/repos/content-manager/owner/content-manager/releases. Where the first "content-manager" is whatever comes after "owner/".

It does work when I specify "owner" so I am unblocked. Thanks again!

@develar I used the configuration for publishing to the github-enterprise as mentioned above in one of the comments but url shows up as https://github.***.com/api/v3/repos/usernmae/repo-name.git/releases and gives me an error as follows:

HttpError: 404 Not Found
"method: undefined url: https://github.***.com/api/v3/repos/usernmae/repo-name.git/releases" Please double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404."

I understand that it is asking me for further authentication. How can I fix this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philcockfield picture philcockfield  ·  3Comments

AidanNichol picture AidanNichol  ·  3Comments

iklemm picture iklemm  ·  3Comments

omarkilani picture omarkilani  ·  3Comments

NPellet picture NPellet  ·  3Comments